public void BetaMeanTest()
        {
            double alpha = 0.42;
            double beta  = 1.57;

            BetaDistribution betaDistribution = new BetaDistribution(alpha, beta);

            double mean   = betaDistribution.Mean;                                                     // 0.21105527638190955
            double median = betaDistribution.Median;                                                   // 0.11577706212908731
            double var    = betaDistribution.Variance;                                                 // 0.055689279830523512
            double chf    = betaDistribution.CumulativeHazardFunction(x: 0.27);                        // 1.1828193992944409
            double cdf    = betaDistribution.DistributionFunction(x: 0.27);                            // 0.69358638272337991
            double pdf    = betaDistribution.ProbabilityDensityFunction(x: 0.27);                      // 0.94644031936694828
            double lpdf   = betaDistribution.LogProbabilityDensityFunction(x: 0.27);                   // -0.055047364344046057
            double hf     = betaDistribution.HazardFunction(x: 0.27);                                  // 3.0887671630877072
            double ccdf   = betaDistribution.ComplementaryDistributionFunction(x: 0.27);               // 0.30641361727662009
            double icdf   = betaDistribution.InverseDistributionFunction(p: cdf);                      // 0.26999999068687469

            string str = betaDistribution.ToString(System.Globalization.CultureInfo.InvariantCulture); // "B(x; α = 0.42, β = 1.57)

            Assert.AreEqual(0.21105527638190955, mean);
            Assert.AreEqual(0.11577706212908731, median);
            Assert.AreEqual(0.055689279830523512, var);
            Assert.AreEqual(1.1828193992944409, chf);
            Assert.AreEqual(0.69358638272337991, cdf);
            Assert.AreEqual(0.94644031936694828, pdf);
            Assert.AreEqual(-0.055047364344046057, lpdf);
            Assert.AreEqual(3.0887671630877072, hf);
            Assert.AreEqual(0.30641361727662009, ccdf);
            Assert.AreEqual(0.27, icdf, 1e-10);
            Assert.AreEqual("B(x; α = 0.42, β = 1.57)", str);

            Assert.IsFalse(Double.IsNaN(median));
        }
        public void BetaMeanTest()
        {
            double alpha = 0.42;
            double beta  = 1.57;

            BetaDistribution betaDistribution = new BetaDistribution(alpha, beta);

            double mean   = betaDistribution.Mean;                                                     // 0.21105527638190955
            double median = betaDistribution.Median;                                                   // 0.11577706212908731
            double var    = betaDistribution.Variance;                                                 // 0.055689279830523512
            double mode   = betaDistribution.Mode;                                                     // 57.999999999999957

            double chf  = betaDistribution.CumulativeHazardFunction(x: 0.27);                          // 1.1828193992944409
            double cdf  = betaDistribution.DistributionFunction(x: 0.27);                              // 0.69358638272337991
            double pdf  = betaDistribution.ProbabilityDensityFunction(x: 0.27);                        // 0.94644031936694828
            double lpdf = betaDistribution.LogProbabilityDensityFunction(x: 0.27);                     // -0.055047364344046057
            double hf   = betaDistribution.HazardFunction(x: 0.27);                                    // 3.0887671630877072
            double ccdf = betaDistribution.ComplementaryDistributionFunction(x: 0.27);                 // 0.30641361727662009
            double icdf = betaDistribution.InverseDistributionFunction(p: cdf);                        // 0.26999999068687469

            string str = betaDistribution.ToString(System.Globalization.CultureInfo.InvariantCulture); // "B(x; α = 0.42, β = 1.57)

            Assert.AreEqual(0.21105527638190955, mean);
            Assert.AreEqual(0.11577706212908731, median);
            Assert.AreEqual(57.999999999999957, mode);
            Assert.AreEqual(0.055689279830523512, var);
            Assert.AreEqual(1.1828193992944409, chf);
            Assert.AreEqual(0.69358638272337991, cdf);
            Assert.AreEqual(0.94644031936694828, pdf);
            Assert.AreEqual(-0.055047364344046057, lpdf);
            Assert.AreEqual(3.0887671630877072, hf);
            Assert.AreEqual(0.30641361727662009, ccdf);
            Assert.AreEqual(0.27, icdf, 1e-10);
            Assert.AreEqual("B(x; α = 0.42, β = 1.57)", str);

            Assert.IsFalse(Double.IsNaN(median));

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

            Assert.AreEqual(0.00045925525776717733, range1.Min);
            Assert.AreEqual(0.72381020663218609, range1.Max);
            Assert.AreEqual(0.0000099485893745082635, range2.Min);
            Assert.AreEqual(0.89625688707910811, range2.Max);
            Assert.AreEqual(0.0000099485893745082432, range3.Min);
            Assert.AreEqual(0.89625688707910811, range3.Max);

            Assert.AreEqual(0, betaDistribution.Support.Min);
            Assert.AreEqual(1, betaDistribution.Support.Max);

            Assert.AreEqual(betaDistribution.InverseDistributionFunction(0), betaDistribution.Support.Min);
            Assert.AreEqual(betaDistribution.InverseDistributionFunction(1), betaDistribution.Support.Max);
        }