public void TestMethod1()
        {
            Distribution n0 = new TransformedDistribution(new NormalDistribution(), -2.0, 3.0);
            Distribution n1 = new NormalDistribution(-2.0, 3.0);

            Assert.IsTrue(TestUtilities.IsNearlyEqual(n0.Mean, n1.Mean));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(n0.Variance, n1.Variance));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(n0.StandardDeviation, n1.StandardDeviation));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(n0.Skewness, n1.Skewness));

            for (int k = 0; k < 8; k++) {
                Assert.IsTrue(TestUtilities.IsNearlyEqual(n0.Moment(k), n1.Moment(k)));
                Assert.IsTrue(TestUtilities.IsNearlyEqual(n0.MomentAboutMean(k), n1.MomentAboutMean(k)));
            }

            foreach (double x in TestUtilities.GenerateUniformRealValues(-8.0, 8.0, 8)) {
                Assert.IsTrue(TestUtilities.IsNearlyEqual(n0.ProbabilityDensity(x), n1.ProbabilityDensity(x)));
                Assert.IsTrue(TestUtilities.IsNearlyEqual(n0.LeftProbability(x), n1.LeftProbability(x)));
                Assert.IsTrue(TestUtilities.IsNearlyEqual(n0.RightProbability(x), n1.RightProbability(x)));
            }

            foreach (double P in TestUtilities.GenerateRealValues(1.0E-4, 1.0, 4)) {
                Assert.IsTrue(TestUtilities.IsNearlyEqual(n0.InverseLeftProbability(P), n1.InverseLeftProbability(P)));
                Assert.IsTrue(TestUtilities.IsNearlyEqual(n0.InverseRightProbability(P), n1.InverseRightProbability(P)));
            }
        }
示例#2
0
 /// <inheritdoc />
 public override double LeftProbability(double x)
 {
     if (x <= 0.0)
     {
         return(0.0);
     }
     else
     {
         return(normal.LeftProbability(Math.Log(x)));
     }
 }
示例#3
0
        /// <inheritdoc />
        public override double LeftProbability(double x)
        {
            if (x <= 0.0)
            {
                return(0.0);
            }
            else
            {
                return(normal.LeftProbability(Math.Log(x)));
            }

            /*
             * double z = (Math.Log(x) - mu) / sigma;
             * return (NormalDistribution.Phi(z));
             */
        }
示例#4
0
        public void TestNormalOrderStatistic()
        {
            int n = 100;
            //int r = 3 * n / 4;
            int r = 52;
            Distribution d = new NormalDistribution();

            double C = Math.Exp(AdvancedIntegerMath.LogFactorial(n) - AdvancedIntegerMath.LogFactorial(r - 1) - AdvancedIntegerMath.LogFactorial(n - r));

            double m = GaussHermiteIntegrate(x => C * MoreMath.Pow(d.LeftProbability(x), r - 1) * MoreMath.Pow(d.RightProbability(x), n - r) * x);
            //double m = GaussHermiteIntegrate(x => 1.0);

            double m2 = FunctionMath.Integrate(
                //x => 1.0 * Math.Exp(-x * x / 2.0) / Math.Sqrt(2.0 * Math.PI),
                x => C * MoreMath.Pow(d.LeftProbability(x), r - 1) * MoreMath.Pow(d.RightProbability(x), n - r) * x * Math.Exp(-x * x / 2.0) / Math.Sqrt(2.0 * Math.PI),
                Interval.FromEndpoints(Double.NegativeInfinity, Double.PositiveInfinity)
            );

            Console.WriteLine(m);
            Console.WriteLine(m2);
            Console.WriteLine(NormalMeanOrderStatisticExpansion(r, n));
            Console.WriteLine(NormalMeanOrderStatisticExpansion2(r, n));
            //Console.WriteLine(1.5 / Math.Sqrt(Math.PI));
        }