Accord.Statistics.Distributions.Univariate.BetaPrimeDistribution.ProbabilityDensityFunction C# (CSharp) Method

ProbabilityDensityFunction() public method

Gets the probability density function (pdf) for this distribution evaluated at point x.
The Probability Density Function (PDF) describes the probability that a given value x will occur.
public ProbabilityDensityFunction ( [ x ) : double
x [ A single point in the distribution range.
return double
        public override double ProbabilityDensityFunction([Positive] double x)
        {
            if (x <= 0)
                return 0;

            double num = Math.Pow(x, alpha - 1) * Math.Pow(1 + x, -alpha - beta);
            double den = Accord.Math.Beta.Function(alpha, beta);
            return num / den;
        }

Usage Example

        public void Constructor_ExtensiveTestForDocumentation()
        {
            // Create a new Beta-Prime distribution with shape (4,2)
            var betaPrime = new BetaPrimeDistribution(alpha: 4, beta: 2);

            double mean = betaPrime.Mean;     // 4.0
            double median = betaPrime.Median; // 2.1866398762435981
            double mode = betaPrime.Mode;     // 1.0
            double var = betaPrime.Variance;  // +inf

            double cdf = betaPrime.DistributionFunction(x: 0.4);           // 0.02570357589099781
            double pdf = betaPrime.ProbabilityDensityFunction(x: 0.4);     // 0.16999719504628183
            double lpdf = betaPrime.LogProbabilityDensityFunction(x: 0.4); // -1.7719733417957513

            double ccdf = betaPrime.ComplementaryDistributionFunction(x: 0.4); // 0.97429642410900219
            double icdf = betaPrime.InverseDistributionFunction(p: cdf);       // 0.39999982363709291

            double hf = betaPrime.HazardFunction(x: 0.4);            // 0.17448200654307533
            double chf = betaPrime.CumulativeHazardFunction(x: 0.4); // 0.026039684773113869

            string str = betaPrime.ToString(CultureInfo.InvariantCulture); // BetaPrime(x; α = 4, β = 2)

            Assert.AreEqual(4, betaPrime.Alpha);
            Assert.AreEqual(2, betaPrime.Beta);

            Assert.AreEqual(4.0, mean);
            Assert.AreEqual(2.1866398762435981, median);
            Assert.AreEqual(1.0, mode);
            Assert.AreEqual(double.PositiveInfinity, var);
            Assert.AreEqual(0.026039684773113869, chf);
            Assert.AreEqual(0.02570357589099781, cdf);
            Assert.AreEqual(0.16999719504628183, pdf);
            Assert.AreEqual(-1.7719733417957513, lpdf);
            Assert.AreEqual(0.17448200654307533, hf);
            Assert.AreEqual(0.97429642410900219, ccdf);
            Assert.AreEqual(0.39999982363709291, icdf);
            Assert.AreEqual("BetaPrime(x; α = 4, β = 2)", str);

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

            Assert.AreEqual(0.52112465307247502, range1.Min);
            Assert.AreEqual(12.082089043372052, range1.Max);
            Assert.AreEqual(0.28546647531958014, range2.Min);
            Assert.AreEqual(29.597777621141635, range2.Max);
            Assert.AreEqual(range2.Min, range3.Min, 1e-15);
            Assert.AreEqual(range2.Max, range3.Max, 1e-15);
        }
All Usage Examples Of Accord.Statistics.Distributions.Univariate.BetaPrimeDistribution::ProbabilityDensityFunction