gammainc
Regularized incomplete gamma function.
Category: Mathematics > Elementary Math
Syntax
P = gammainc(X, A)
Returns the lower regularized incomplete gamma function P(A, X).
Q = gammainc(X, A, tail)
Selects the tail: 'lower' (default), 'upper' for 1 - P, or 'scaledlower' / 'scaledupper' for the scaled versions.
Description
The lower function is the integral of t^(A-1)*exp(-t) from 0 to X, divided by gamma(A). It rises from 0 to 1 as X grows, so it is the cumulative distribution function of the gamma distribution with unit scale. With A = 1 it reduces to 1 - exp(-X), and gammainc(x/2, k/2) is the chi-square CDF with k degrees of freedom.
Use 'upper' rather than 1 - gammainc(...) when the tail is tiny, since the subtraction loses all significant digits.
Input arguments
X- Nonnegative real array, the upper limit of the integral.
A- Positive real array, the shape parameter. Sizes of
XandAmust be compatible. tail- Character vector naming the tail to compute.
Output arguments
P- Values in the interval from 0 to 1 (for the unscaled tails).
Example
Lower and upper tails
gammainc(1, 2)
gammainc(1, 2, 'upper')
gammainc([0.5 1 2], 1)
Output
ans = 0.2642
ans = 0.7358
ans = 1×3
0.3935 0.6321 0.8647