public void ConstructorTest()
        {
            var bern = new BernoulliDistribution(mean: 0.42);

            // Common measures
            double mean = bern.Mean;     // 0.42
            double median = bern.Median; // 0.0
            double var = bern.Variance;  // 0.2436
            double mode = bern.Mode;     // 0.0

            // Probability mass functions
            double pdf = bern.ProbabilityMassFunction(k: 1); // 0.42
            double lpdf = bern.LogProbabilityMassFunction(k: 0); // -0.54472717544167193

            // Cumulative distribution function
            double cdf = bern.DistributionFunction(k: 0);    // 0.58
            double ccdf = bern.ComplementaryDistributionFunction(k: 0); // 0.42

            // Quantile function
            int icdf0 = bern.InverseDistributionFunction(p: 0.57); // 0
            int icdf1 = bern.InverseDistributionFunction(p: 0.59); // 1

            double hf = bern.HazardFunction(x: 0); // 1.3809523809523814
            double chf = bern.CumulativeHazardFunction(x: 0); // 0.86750056770472328

            string str = bern.ToString(CultureInfo.InvariantCulture); // "Bernoulli(x; p = 0.42, q = 0.58)"

            Assert.AreEqual(0.42, mean);
            Assert.AreEqual(0.0, median);
            Assert.AreEqual(0.2436, var);
            Assert.AreEqual(0.0, mode);
            Assert.AreEqual(0.86750056770472328, chf, 1e-10);
            Assert.AreEqual(0.58, cdf, 1e-10);
            Assert.AreEqual(0.42, pdf);
            Assert.AreEqual(-0.54472717544167193, lpdf);
            Assert.AreEqual(1.3809523809523814, hf, 1e-10);
            Assert.AreEqual(0.42, ccdf, 1e-10);
            Assert.AreEqual(0, icdf0);
            Assert.AreEqual(1, icdf1);
            Assert.AreEqual("Bernoulli(x; p = 0.42, q = 0.58)", str);

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

            Assert.AreEqual(0, range1.Min);
            Assert.AreEqual(1.0, range1.Max);
            Assert.AreEqual(0, range2.Min);
            Assert.AreEqual(1.0, range2.Max);
            Assert.AreEqual(0, range3.Min);
            Assert.AreEqual(1.0, range3.Max);
        }
        public void MedianTest()
        {
            {
                BernoulliDistribution target = new BernoulliDistribution(0.2);
                Assert.AreEqual(target.Median, target.InverseDistributionFunction(0.5));
            }

            {
                BernoulliDistribution target = new BernoulliDistribution(0.6);
                Assert.AreEqual(target.Median, target.InverseDistributionFunction(0.5));
            }

            {
                BernoulliDistribution target = new BernoulliDistribution(0.0);
                Assert.AreEqual(target.Median, target.InverseDistributionFunction(0.5));
            }

            {
                BernoulliDistribution target = new BernoulliDistribution(1.0);
                Assert.AreEqual(target.Median, target.InverseDistributionFunction(0.5));
            }
        }