DistributionFunction() public method

Gets the cumulative distribution function (cdf) for this distribution evaluated at point k.
The Cumulative Distribution Function (CDF) describes the cumulative probability that a given value or any value smaller than it will occur.
public DistributionFunction ( double x ) : double
x double A single point in the distribution range.
return double
        public void ConstructorTest()
        {
            double[] ranks = { 1, 2, 3, 4, 5 };

            var mannWhitney = new MannWhitneyDistribution(ranks, n1: 2, n2: 3);

            double mean = mannWhitney.Mean;     // 2.7870954605658511
            double median = mannWhitney.Median; // 1.5219615583481305
            double var = mannWhitney.Variance;  // 18.28163603621158

            double cdf = mannWhitney.DistributionFunction(x: 4); // 0.6
            double pdf = mannWhitney.ProbabilityDensityFunction(x: 4); // 0.2
            double lpdf = mannWhitney.LogProbabilityDensityFunction(x: 4); // -1.6094379124341005

            double ccdf = mannWhitney.ComplementaryDistributionFunction(x: 4); // 0.4
            double icdf = mannWhitney.InverseDistributionFunction(p: cdf); // 3.6666666666666661

            double hf = mannWhitney.HazardFunction(x: 4); // 0.5
            double chf = mannWhitney.CumulativeHazardFunction(x: 4); // 0.916290731874155

            string str = mannWhitney.ToString(); // MannWhitney(u; n1 = 2, n2 = 3)

            Assert.AreEqual(3.0, mean);
            Assert.AreEqual(3.0000006357828775, median);
            Assert.AreEqual(3.0, var);
            Assert.AreEqual(0.916290731874155, chf);
            Assert.AreEqual(0.6, cdf);
            Assert.AreEqual(0.2, pdf);
            Assert.AreEqual(-1.6094379124341005, lpdf);
            Assert.AreEqual(0.5, hf);
            Assert.AreEqual(0.4, ccdf);
            Assert.AreEqual(3.6666666666666661, icdf);
            Assert.AreEqual("MannWhitney(u; n1 = 2, n2 = 3)", str);
        }
        public void ConstructorTest()
        {
            double[] ranks = { 1, 2, 3, 4, 5 };

            var mannWhitney = new MannWhitneyDistribution(ranks, n1: 2, n2: 3);

            double mean = mannWhitney.Mean;     // 2.7870954605658511
            double median = mannWhitney.Median; // 1.5219615583481305
            double var = mannWhitney.Variance;  // 18.28163603621158
            try { double mode = mannWhitney.Mode; Assert.Fail(); }
            catch { }

            double cdf = mannWhitney.DistributionFunction(x: 4); // 0.6
            double pdf = mannWhitney.ProbabilityDensityFunction(x: 4); // 0.2
            double lpdf = mannWhitney.LogProbabilityDensityFunction(x: 4); // -1.6094379124341005

            double ccdf = mannWhitney.ComplementaryDistributionFunction(x: 4); // 0.4
            double icdf = mannWhitney.InverseDistributionFunction(p: cdf); // 3.6666666666666661

            double hf = mannWhitney.HazardFunction(x: 4); // 0.5
            double chf = mannWhitney.CumulativeHazardFunction(x: 4); // 0.916290731874155

            string str = mannWhitney.ToString(); // MannWhitney(u; n1 = 2, n2 = 3)

            Assert.AreEqual(3.0, mean);
            Assert.AreEqual(3.0000006357828775, median);
            Assert.AreEqual(3.0, var);
            Assert.AreEqual(0.916290731874155, chf);
            Assert.AreEqual(0.6, cdf);
            Assert.AreEqual(0.2, pdf);
            Assert.AreEqual(-1.6094379124341005, lpdf);
            Assert.AreEqual(0.5, hf);
            Assert.AreEqual(0.4, ccdf);
            Assert.AreEqual(3.6666666666666661, icdf);
            Assert.AreEqual("MannWhitney(u; n1 = 2, n2 = 3)", str);

            var range1 = mannWhitney.GetRange(0.95);
            var range2 = mannWhitney.GetRange(0.99);
            var range3 = mannWhitney.GetRange(0.01);

            Assert.AreEqual(0.00000095367431640625085, range1.Min);
            Assert.AreEqual(5.9999995430310555, range1.Max);
            Assert.AreEqual(0, range2.Min);
            Assert.AreEqual(6.000000194140088, range2.Max);
            Assert.AreEqual(0, range3.Min);
            Assert.AreEqual(6.000000194140088, range3.Max);
        }
        public void DistributionFunctionTest()
        {
            double[] ranks = { 1, 2, 3, 4, 5 };

            int n1 = 2;
            int n2 = 3;
            int N = n1 + n2;

            Assert.AreEqual(N, ranks.Length);


            var target = new MannWhitneyDistribution(ranks, n1, n2);

            // Number of possible combinations is 5!/(3!2!) = 10.
            int nc = (int)Special.Binomial(5, 3);

            Assert.AreEqual(10, nc);

            double[] expected = { 0.0, 0.1, 0.1, 0.2, 0.2, 0.2, 0.1, 0.1, 0.0, 0.0 };
            expected = expected.CumulativeSum();

            for (int i = 0; i < expected.Length; i++)
            {
                // P(U<=i)
                double actual = target.DistributionFunction(i);
                Assert.AreEqual(expected[i], actual,1e-10);
            }

        }