scipy.special.gammainc
- scipy.special.gammainc(a, x, out=None) = <ufunc 'gammainc'>
Regularized lower incomplete gamma function.
It is defined as
Regularized lower incomplete gamma function.
It is defined as
for and . See [dlmf] for details.
Positive parameter
Nonnegative argument
Optional output array for the function values
Values of the lower incomplete gamma function
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].
Array API Standard Support
gammainc has experimental support for Python Array API Standard compatible
backends in addition to NumPy. Please consider testing these features
by setting an environment variable SCIPY_ARRAY_API=1 and providing
CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following
combinations of backend and device (or other capability) are supported.
Library | CPU | GPU |
|---|---|---|
NumPy | ✅ | n/a |
CuPy | n/a | ✅ |
PyTorch | ✅ | ✅ |
JAX | ✅ | ✅ |
Dask | ✅ | n/a |
See Support for the array API standard for more information.
NIST Digital Library of Mathematical functions https://dlmf.nist.gov/8.2#E4
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
>>> 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