|
Cumulative
Probability
Distribution Functions
License: BSD style: see license.txt Authors: Stephen L. Moshier (original C code), Don Clugston
Computes the integral from minus infinity to t of the Student t distribution with integer nu > 0 degrees of freedom: Γ( (nu+1)/2) / ( sqrt(nu π) Γ(nu/2) ) * ∫-∞t (1+x2/nu)-(nu+1)/2 dx Can be used to test whether the means of two normally distributed populations are equal. It is related to the incomplete beta integral: 1 - studentsDistribution(nu,t) = 0.5 * betaDistribution( nu/2, 1/2, z ) where z = nu/(nu + t2). For t < -1.6, this is the method of computation. For higher t, a direct method is derived from integration by parts. Since the function is symmetric about t=0, the area under the right tail of the density is found by calling the function with -t instead of t. Given probability p and degrees of freedom nu, finds the argument t such that the one-sided studentsDistribution(nu,t) is equal to p. Params:
real fDistributionCompl (int df1, int df2, real x); real fDistributionComplInv (int df1, int df2, real p); The F density function (also known as Snedcor's density or the variance ratio density) is the density of x = (u1/df1)/(u2/df2), where u1 and u2 are random variables having χ2 distributions with df1 and df2 degrees of freedom, respectively. fDistribution returns the area from zero to x under the F density function. The complementary function, fDistributionCompl, returns the area from x to ∞ under the F density function. The inverse of the complemented F distribution, fDistributionComplInv, finds the argument x such that the integral from x to infinity of the F density is equal to the given probability y. Can be used to test whether the means of multiple normally distributed populations, all with the same standard deviation, are equal; or to test that the standard deviations of two normally distributed populations are equal. Params:
real chiSqrDistributionCompl (real v, real x); Returns the area under the left hand tail (from 0 to x) of the Chi square probability density function with v degrees of freedom. The complement returns the area under the right hand tail (from x to ∞). chiSqrDistribution (x | v) = (∫0x tv/2-1 e-t/2 dt ) / 2v/2 Γ(v/2) chiSqrDistributionCompl(x | v) = (∫x∞ tv/2-1 e-t/2 dt ) / 2v/2 Γ(v/2) Params:
Finds the χ2 argument x such that the integral from x to ∞ of the χ2 density is equal to the given cumulative probability p. Params:
real gammaDistributionCompl (real a, real b, real x); The Γ distribution is defined as the integral from 0 to x of the gamma probability density function. The complementary function returns the integral from x to ∞ gammaDistribution = (∫0x tb-1e-at dt) ab/Γ(b) x must be greater than 0. real betaDistributionCompl (real a, real b, real x); real betaDistributionInv (real a, real b, real y); real betaDistributionComplInv (real a, real b, real y); Returns the incomplete beta integral of the arguments, evaluated from zero to x. The function is defined as betaDistribution = Γ(a+b)/(Γ(a) Γ(b)) * ∫0x ta-1(1-t)b-1 dt The domain of definition is 0 <= x <= 1. In this implementation a and b are restricted to positive values. The integral from x to 1 may be obtained by the symmetry relation betaDistributionCompl(a, b, x ) = betaDistribution ( b, a, 1-x ) The integral is evaluated by a continued fraction expansion or, when b*x is small, by a power series. The inverse finds the value of x for which betaDistribution (a,b,x) - y = 0 real poissonDistributionCompl (int k, real m); real poissonDistributionInv (int k, real p); k is the number of events. m is the mean. The Poisson distribution is defined as the sum of the first k terms of the Poisson density function. The complement returns the sum of the terms k+1 to ∞. poissonDistribution = Σ kj=0 e-m mj/j! poissonDistributionCompl = Σ ∞j=k+1 e-m mj/j! The terms are not summed directly; instead the incomplete gamma integral is employed, according to the relation y = poissonDistribution ( k, m ) = gammaIncompleteCompl( k+1, m ). The arguments must both be positive. real binomialDistributionCompl (int k, int n, real p); The binomial distribution is defined as the sum of the terms 0 through k of the Binomial probability density. The complement returns the sum of the terms k+1 through n. binomialDistribution = Σ kj=0 ( nj ) pj (1-p)n-j binomialDistributionCompl = Σ nj=k+1 ( nj ) pj (1-p)n-j The terms are not summed directly; instead the incomplete beta integral is employed, according to the formula y = binomialDistribution ( k, n, p ) = betaDistribution( n-k, k+1, 1-p ). The arguments must be positive, with p ranging from 0 to 1, and k<=n. Finds the event probability p such that the sum of the terms 0 through k of the Binomial probability density is equal to the given cumulative probability y. This is accomplished using the inverse beta integral function and the relation 1 - p = betaDistributionInv( n-k, k+1, y ). The arguments must be positive, with 0 <= y <= 1, and k <= n. real negativeBinomialDistributionInv (int k, int n, real p); Returns the sum of the terms 0 through k of the negative binomial distribution: Σ kj=0 ( n+j-1j-1 ) pn (1-p)j In a sequence of Bernoulli trials, this is the probability that k or fewer failures precede the n-th success. The arguments must be positive, with 0 < p < 1 and r>0. The inverse finds the argument y such that negativeBinomialDistribution (k,n,y) is equal to p. The Geometric Distribution is a special case of the negative binomial distribution. geometricDistribution(k, p) = negativeBinomialDistribution(k, 1, p); References: http://mathworld.wolfram.com/NegativeBinomialDistribution.html | ||||||||||||||||||
| Based on the CEPHES math library, which is Copyright (C) 1994 Stephen L. Moshier (moshier@world.std.com). :: page rendered by CandyDoc |