scipy.special.gammainc#

scipy.special.gammainc(a, x) = <ufunc 'gammainc'>#

Regularized lower incomplete gamma function.

It is defined as

\[P(a, x) = \frac{1}{\Gamma(a)} \int_0^x t^{a - 1}e^{-t} dt\]

for \(a > 0\) and \(x \geq 0\). See [dlmf] for details.

Parameters
aarray_like

Positive parameter

xarray_like

Nonnegative argument

Returns
scalar or ndarray

Values of the lower incomplete gamma function

See also

gammaincc

regularized upper incomplete gamma function

gammaincinv

inverse of the regularized lower incomplete gamma function

gammainccinv

inverse of the regularized upper incomplete gamma function

Notes

The function satisfies the relation gammainc(a, x) + gammaincc(a, x) = 1 where gammaincc is the regularized upper incomplete gamma function.

The implementation largely follows that of [boost].

References

dlmf

NIST Digital Library of Mathematical functions https://dlmf.nist.gov/8.2#E4

boost

Maddock et. al., “Incomplete Gamma Functions”, https://www.boost.org/doc/libs/1_61_0/libs/math/doc/html/math_toolkit/sf_gamma/igamma.html

Examples

>>> import scipy.special as sc

It is the CDF of the gamma distribution, so it starts at 0 and monotonically increases to 1.

>>> sc.gammainc(0.5, [0, 1, 10, 100])
array([0.        , 0.84270079, 0.99999226, 1.        ])

It is equal to one minus the upper incomplete gamma function.

>>> a, x = 0.5, 0.4
>>> sc.gammainc(a, x)
0.6289066304773024
>>> 1 - sc.gammaincc(a, x)
0.6289066304773024