public void Issue_632()
        {
            // https://github.com/accord-net/framework/issues/632

            var n = new ExponentialDistribution(4.2);

            Assert.AreEqual(0, n.DistributionFunction(-10));
            Assert.AreEqual(0, n.ProbabilityDensityFunction(-10));
            Assert.AreEqual(System.Math.Log(0), n.LogProbabilityDensityFunction(-10));

            Assert.AreEqual(0, n.DistributionFunction(0));
            Assert.AreEqual(4.2, n.ProbabilityDensityFunction(0));
            Assert.AreEqual(System.Math.Log(4.2), n.LogProbabilityDensityFunction(0));
        }
        public void ConstructorTest2()
        {
            var exp = new ExponentialDistribution(rate: 0.42);

            double mean = exp.Mean;     // 2.3809523809523809
            double median = exp.Median; // 1.6503504299046317
            double var = exp.Variance;  // 5.6689342403628125

            double cdf = exp.DistributionFunction(x: 0.27); // 0.10720652870550407
            double pdf = exp.ProbabilityDensityFunction(x: 0.27); // 0.3749732579436883
            double lpdf = exp.LogProbabilityDensityFunction(x: 0.27); // -0.98090056770472311

            double ccdf = exp.ComplementaryDistributionFunction(x: 0.27); // 0.89279347129449593
            double icdf = exp.InverseDistributionFunction(p: cdf); // 0.27

            double hf = exp.HazardFunction(x: 0.27); // 0.42
            double chf = exp.CumulativeHazardFunction(x: 0.27); // 0.1134

            string str = exp.ToString(CultureInfo.InvariantCulture); // Exp(x; λ = 0.42)

            Assert.AreEqual(2.3809523809523809, mean);
            Assert.AreEqual(1.6503504299046317, median);
            Assert.AreEqual(5.6689342403628125, var);
            Assert.AreEqual(0.1134, chf);
            Assert.AreEqual(0.10720652870550407, cdf);
            Assert.AreEqual(0.3749732579436883, pdf);
            Assert.AreEqual(-0.98090056770472311, lpdf);
            Assert.AreEqual(0.42, hf);
            Assert.AreEqual(0.89279347129449593, ccdf);
            Assert.AreEqual(0.27, icdf);
            Assert.AreEqual("Exp(x; λ = 0.42)", str);
        }
        public void ConstructorTest2()
        {
            var exp = new ExponentialDistribution(rate: 0.42);

            double mean   = exp.Mean;                                     // 2.3809523809523809
            double median = exp.Median;                                   // 1.6503504299046317
            double var    = exp.Variance;                                 // 5.6689342403628125

            double cdf  = exp.DistributionFunction(x: 0.27);              // 0.10720652870550407
            double pdf  = exp.ProbabilityDensityFunction(x: 0.27);        // 0.3749732579436883
            double lpdf = exp.LogProbabilityDensityFunction(x: 0.27);     // -0.98090056770472311

            double ccdf = exp.ComplementaryDistributionFunction(x: 0.27); // 0.89279347129449593
            double icdf = exp.InverseDistributionFunction(p: cdf);        // 0.27

            double hf  = exp.HazardFunction(x: 0.27);                     // 0.42
            double chf = exp.CumulativeHazardFunction(x: 0.27);           // 0.1134

            string str = exp.ToString(CultureInfo.InvariantCulture);      // Exp(x; λ = 0.42)

            Assert.AreEqual(2.3809523809523809, mean);
            Assert.AreEqual(1.6503504299046317, median);
            Assert.AreEqual(5.6689342403628125, var);
            Assert.AreEqual(0.1134, chf);
            Assert.AreEqual(0.10720652870550407, cdf);
            Assert.AreEqual(0.3749732579436883, pdf);
            Assert.AreEqual(-0.98090056770472311, lpdf);
            Assert.AreEqual(0.42, hf);
            Assert.AreEqual(0.89279347129449593, ccdf);
            Assert.AreEqual(0.27, icdf);
            Assert.AreEqual("Exp(x; λ = 0.42)", str);
        }
        public void ConstructorTest2()
        {
            var exp = new ExponentialDistribution(rate: 0.42);

            double mean   = exp.Mean;                                     // 2.3809523809523809
            double median = exp.Median;                                   // 1.6503504299046317
            double var    = exp.Variance;                                 // 5.6689342403628125
            double mode   = exp.Mode;                                     // 0.0

            double cdf  = exp.DistributionFunction(x: 0.27);              // 0.10720652870550407
            double pdf  = exp.ProbabilityDensityFunction(x: 0.27);        // 0.3749732579436883
            double lpdf = exp.LogProbabilityDensityFunction(x: 0.27);     // -0.98090056770472311

            double ccdf = exp.ComplementaryDistributionFunction(x: 0.27); // 0.89279347129449593
            double icdf = exp.InverseDistributionFunction(p: cdf);        // 0.27

            double hf  = exp.HazardFunction(x: 0.27);                     // 0.42
            double chf = exp.CumulativeHazardFunction(x: 0.27);           // 0.1134

            string str = exp.ToString(CultureInfo.InvariantCulture);      // Exp(x; λ = 0.42)

            Assert.AreEqual(2.3809523809523809, mean);
            Assert.AreEqual(1.6503504299046317, median);
            Assert.AreEqual(0.0, mode);
            Assert.AreEqual(5.6689342403628125, var);
            Assert.AreEqual(0.1134, chf);
            Assert.AreEqual(0.10720652870550407, cdf);
            Assert.AreEqual(0.3749732579436883, pdf);
            Assert.AreEqual(-0.98090056770472311, lpdf);
            Assert.AreEqual(0.42, hf);
            Assert.AreEqual(0.89279347129449593, ccdf);
            Assert.AreEqual(0.27, icdf);
            Assert.AreEqual("Exp(x; λ = 0.42)", str);

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

            Assert.AreEqual(0.12212689139892995, range1.Min);
            Assert.AreEqual(7.1326958894142622, range1.Max);
            Assert.AreEqual(0.023929371079765359, range2.Min);
            Assert.AreEqual(10.964690919019265, range2.Max);
            Assert.AreEqual(0.023929371079765359, range3.Min);
            Assert.AreEqual(10.964690919019265, range3.Max);
        }
        public void ConstructorTest2()
        {
            var exp = new ExponentialDistribution(rate: 0.42);

            double mean = exp.Mean;     // 2.3809523809523809
            double median = exp.Median; // 1.6503504299046317
            double var = exp.Variance;  // 5.6689342403628125
            double mode = exp.Mode;     // 0.0

            double cdf = exp.DistributionFunction(x: 0.27); // 0.10720652870550407
            double pdf = exp.ProbabilityDensityFunction(x: 0.27); // 0.3749732579436883
            double lpdf = exp.LogProbabilityDensityFunction(x: 0.27); // -0.98090056770472311

            double ccdf = exp.ComplementaryDistributionFunction(x: 0.27); // 0.89279347129449593
            double icdf = exp.InverseDistributionFunction(p: cdf); // 0.27

            double hf = exp.HazardFunction(x: 0.27); // 0.42
            double chf = exp.CumulativeHazardFunction(x: 0.27); // 0.1134

            string str = exp.ToString(CultureInfo.InvariantCulture); // Exp(x; λ = 0.42)

            Assert.AreEqual(2.3809523809523809, mean);
            Assert.AreEqual(1.6503504299046317, median);
            Assert.AreEqual(0.0, mode);
            Assert.AreEqual(5.6689342403628125, var);
            Assert.AreEqual(0.1134, chf);
            Assert.AreEqual(0.10720652870550407, cdf);
            Assert.AreEqual(0.3749732579436883, pdf);
            Assert.AreEqual(-0.98090056770472311, lpdf);
            Assert.AreEqual(0.42, hf);
            Assert.AreEqual(0.89279347129449593, ccdf);
            Assert.AreEqual(0.27, icdf);
            Assert.AreEqual("Exp(x; λ = 0.42)", str);

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

            Assert.AreEqual(0.12212689139892995, range1.Min);
            Assert.AreEqual(7.1326958894142622, range1.Max);
            Assert.AreEqual(0.023929371079765359, range2.Min);
            Assert.AreEqual(10.964690919019265, range2.Max);
            Assert.AreEqual(0.023929371079765359, range3.Min);
            Assert.AreEqual(10.964690919019265, range3.Max);
        }
        public void ProbabilityDistributionTest()
        {
            ExponentialDistribution n = new ExponentialDistribution(3);

            double[] expected = { 3, 0.149361, 0.00743626, 0.000370229, 0.0000184326 };
            double[] actual   = new double[expected.Length];

            for (int i = 0; i < actual.Length; i++)
            {
                actual[i] = n.ProbabilityDensityFunction(i);
            }

            for (int i = 0; i < actual.Length; i++)
            {
                Assert.AreEqual(expected[i], actual[i], 1e-5);
                Assert.IsFalse(double.IsNaN(actual[i]));
            }
        }
        public void ProbabilityDistributionTest2()
        {
            ExponentialDistribution n = new ExponentialDistribution(0.42);

            double[] expected = { 0.42, 0.27596, 0.181318, 0.119135, 0.0782771, 0.0514317 };
            double[] actual   = new double[expected.Length];

            for (int i = 0; i < actual.Length; i++)
            {
                actual[i] = n.ProbabilityDensityFunction(i);
            }

            for (int i = 0; i < actual.Length; i++)
            {
                Assert.AreEqual(expected[i], actual[i], 1e-5);
                Assert.IsFalse(double.IsNaN(actual[i]));
            }
        }
        public void ProbabilityDistributionTest()
        {
            ExponentialDistribution n = new ExponentialDistribution(3);

            double[] expected = { 3, 0.149361, 0.00743626, 0.000370229, 0.0000184326 };
            double[] actual = new double[expected.Length];

            for (int i = 0; i < actual.Length; i++)
                actual[i] = n.ProbabilityDensityFunction(i);

            for (int i = 0; i < actual.Length; i++)
            {
                Assert.AreEqual(expected[i], actual[i], 1e-5);
                Assert.IsFalse(double.IsNaN(actual[i]));
            }
        }
        public void ProbabilityDistributionTest2()
        {
            ExponentialDistribution n = new ExponentialDistribution(0.42);

            double[] expected = { 0.42, 0.27596, 0.181318, 0.119135, 0.0782771, 0.0514317 };
            double[] actual = new double[expected.Length];

            for (int i = 0; i < actual.Length; i++)
                actual[i] = n.ProbabilityDensityFunction(i);

            for (int i = 0; i < actual.Length; i++)
            {
                Assert.AreEqual(expected[i], actual[i], 1e-5);
                Assert.IsFalse(double.IsNaN(actual[i]));
            }
        }