DistributionFunction() public method

Gets the cumulative distribution function (cdf) for this distribution evaluated at point x.

The Cumulative Distribution Function (CDF) describes the cumulative probability that a given value or any value smaller than it will occur.

In the Inverse Gamma CDF is computed in terms of the Upper Incomplete Regularized Gamma Function Q as CDF(x) = Q(a, b / x).

public DistributionFunction ( double x ) : double
x double A single point in the distribution range.
return double
        public void InverseGammaDistributionConstructorTest2()
        {
            var invGamma = new InverseGammaDistribution(shape: 0.42, scale: 0.5);

            double mean = invGamma.Mean;     // -0.86206896551724133
            double median = invGamma.Median; // 3.1072323347401709
            double var = invGamma.Variance;  // -0.47035626665061164

            double cdf = invGamma.DistributionFunction(x: 0.27); // 0.042243552114989695
            double pdf = invGamma.ProbabilityDensityFunction(x: 0.27); // 0.35679850067181362
            double lpdf = invGamma.LogProbabilityDensityFunction(x: 0.27); // -1.0305840804381006
            double ccdf = invGamma.ComplementaryDistributionFunction(x: 0.27); // 0.95775644788501035
            double icdf = invGamma.InverseDistributionFunction(p: cdf); // 0.26999994629410995

            double hf = invGamma.HazardFunction(x: 0.27); // 0.3725357333377633
            double chf = invGamma.CumulativeHazardFunction(x: 0.27); // 0.043161763098266373

            string str = invGamma.ToString(CultureInfo.InvariantCulture); // Γ^(-1)(x; α = 0.42, β = 0.5)

            Assert.AreEqual(-0.86206896551724133, mean);
            Assert.AreEqual(3.1072323347401709, median, 1e-7);
            Assert.AreEqual(-0.47035626665061164, var);
            Assert.AreEqual(0.043161763098266373, chf);
            Assert.AreEqual(0.042243552114989695, cdf, 1e-10);
            Assert.AreEqual(0.35679850067181362, pdf);
            Assert.AreEqual(-1.0305840804381006, lpdf);
            Assert.AreEqual(0.3725357333377633, hf);
            Assert.AreEqual(0.95775644788501035, ccdf);
            Assert.AreEqual(0.27, icdf, 1e-8);
            Assert.AreEqual("Γ^(-1)(x; α = 0.42, β = 0.5)", str);

            double p05 = invGamma.DistributionFunction(median);
            Assert.AreEqual(0.5, p05, 1e-6);
        }
        public void InverseGammaDistributionConstructorTest2()
        {
            var invGamma = new InverseGammaDistribution(shape: 0.42, scale: 0.5);

            double mean = invGamma.Mean;     // -0.86206896551724133
            double median = invGamma.Median; // 3.1072323347401709
            double var = invGamma.Variance;  // -0.47035626665061164
            double mode = invGamma.Mode;     // 0.35211267605633806

            double cdf = invGamma.DistributionFunction(x: 0.27); // 0.042243552114989695
            double pdf = invGamma.ProbabilityDensityFunction(x: 0.27); // 0.35679850067181362
            double lpdf = invGamma.LogProbabilityDensityFunction(x: 0.27); // -1.0305840804381006
            double ccdf = invGamma.ComplementaryDistributionFunction(x: 0.27); // 0.95775644788501035
            double icdf = invGamma.InverseDistributionFunction(p: cdf); // 0.26999994629410995

            double hf = invGamma.HazardFunction(x: 0.27); // 0.3725357333377633
            double chf = invGamma.CumulativeHazardFunction(x: 0.27); // 0.043161763098266373

            string str = invGamma.ToString(CultureInfo.InvariantCulture); // Γ^(-1)(x; α = 0.42, β = 0.5)

            Assert.AreEqual(-0.86206896551724133, mean);
            Assert.AreEqual(3.1072323347401709, median, 1e-7);
            Assert.AreEqual(-0.47035626665061164, var);
            Assert.AreEqual(0.35211267605633806, mode);
            Assert.AreEqual(0.043161763098266373, chf);
            Assert.AreEqual(0.042243552114989695, cdf, 1e-10);
            Assert.AreEqual(0.35679850067181362, pdf);
            Assert.AreEqual(-1.0305840804381006, lpdf);
            Assert.AreEqual(0.3725357333377633, hf);
            Assert.AreEqual(0.95775644788501035, ccdf);
            Assert.AreEqual(0.27, icdf, 1e-7);
            Assert.AreEqual("Γ^(-1)(x; α = 0.42, β = 0.5)", str);

            double p05 = invGamma.DistributionFunction(median);
            Assert.AreEqual(0.5, p05, 1e-6);

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

            Assert.AreEqual(0.29141691452733387, range1.Min);
            Assert.AreEqual(834.10323133076645, range1.Max);
            Assert.AreEqual(0.16305763832571143, range2.Min);
            Assert.AreEqual(38513.540845383861, range2.Max);
            Assert.AreEqual(0.16305763832571132, range3.Min);
            Assert.AreEqual(38513.540845383861, range3.Max);
        }