Example #1
0
        public void ExpOpGammaPowerTest()
        {
            Assert.True(!double.IsNaN(ExpOp.ExpAverageConditional(GammaPower.Uniform(-1), Gaussian.FromNatural(0.046634157098979417, 0.00078302234897204242), Gaussian.Uniform()).Rate));
            Assert.True(!double.IsNaN(ExpOp.ExpAverageConditional(GammaPower.Uniform(-1), Gaussian.FromNatural(0.36153121930654075, 0.0005524890062312658), Gaussian.Uniform()).Rate));
            Assert.True(ExpOp.DAverageConditional(GammaPower.PointMass(0, -1), new Gaussian(0, 1), Gaussian.Uniform()).Point < double.MinValue);
            ExpOp.ExpAverageConditional(GammaPower.FromShapeAndRate(-1, 283.673, -1), Gaussian.FromNatural(0.004859823703146038, 6.6322755562737905E-06), Gaussian.FromNatural(0.00075506803981220758, 8.24487022054953E-07));
            GammaPower exp = GammaPower.FromShapeAndRate(0, 0, -1);

            Gaussian[] ds = new[]
            {
                Gaussian.FromNatural(-1.6171314269768655E+308, 4.8976001759138024),
                Gaussian.FromNatural(-0.037020622891705768, 0.00034989765084474117),
                Gaussian.PointMass(double.NegativeInfinity),
            };
            foreach (var d in ds)
            {
                Gaussian to_d      = ExpOp.DAverageConditional(exp, d, Gaussian.Uniform());
                Gaussian to_d_slow = ExpOp_Slow.DAverageConditional(exp, d);
                Assert.True(to_d_slow.MaxDiff(to_d) < 1e-10);
                to_d = Gaussian.FromNatural(1, 0);
                GammaPower to_exp = ExpOp.ExpAverageConditional(exp, d, to_d);
                //Trace.WriteLine($"{to_exp}");
            }
            ExpOp.ExpAverageConditional(GammaPower.FromShapeAndRate(-1, 883.22399999999993, -1), Gaussian.FromNatural(0.0072160312702854888, 8.1788482512051846E-06), Gaussian.FromNatural(0.00057861649495666474, 5.6316164560235272E-07));
        }
Example #2
0
        public void ExpOpTest()
        {
            Assert.True(ExpOp.ExpAverageConditional(Gamma.FromShapeAndRate(3.302758272196654, 0.00060601537137241492), Gaussian.FromNatural(55.350150233321628, 6.3510247863590683), Gaussian.FromNatural(27.960892513144643, 3.4099170930572216)).Rate > 0);
            Gamma exp = new Gamma(1, 1);

            Gaussian[] ds = new[]
            {
                Gaussian.FromNatural(-1.6171314269768655E+308, 4.8976001759138024),
                Gaussian.PointMass(double.NegativeInfinity),
            };
            foreach (var d in ds)
            {
                Gamma    to_exp    = ExpOp.ExpAverageConditional(exp, d, Gaussian.Uniform());
                Gaussian to_d      = ExpOp.DAverageConditional(exp, d, Gaussian.Uniform());
                Gaussian to_d_slow = ExpOp_Slow.DAverageConditional(exp, d);
                Trace.WriteLine($"{to_d}");
                Trace.WriteLine($"{to_d_slow}");
                Assert.True(to_d_slow.MaxDiff(to_d) < 1e-10);
            }
        }