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 MedianTest()
        {
            double[] ranks = { 1, 1, 2, 3, 4, 7, 5 };

            int n1 = 4;
            int n2 = 3;

            Assert.AreEqual(n1 + n2, ranks.Length);


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

            Assert.AreEqual(target.Median, target.InverseDistributionFunction(0.5));
        }