scipy.special.gammaincc#

scipy.special.gammaincc(a, x, out=None) = <ufunc 'gammaincc'>#

Regularized upper incomplete gamma function.

It is defined as

\[Q(a, x) = \frac{1}{\Gamma(a)} \int_x^\infty 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

outndarray, optional

Optional output array for the function values

Returns:
scalar or ndarray

Values of the upper incomplete gamma function

See also

gammainc

regularized lower 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 gammainc is the regularized lower incomplete gamma function.

The implementation largely follows that of [boost].

Array API Standard Support

gammaincc has support for Python Array API Standard compatible backends in addition to NumPy. 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

For the NumPy backend, this function supports all NumPy ufunc keyword arguments. Other backends may support out, but none of the other ufunc kwargs. out is typically supported for CuPy and PyTorch, but not currently in cases where SciPy relies on a generic Array API implementation or, for PyTorch on CPU, falls back to the NumPy backend. out is never supported for JAX because JAX arrays are immutable.

See Support for the array API standard for more information.

References

[dlmf]

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

Examples

>>> import scipy.special as sc

It is the survival function of the gamma distribution, so it starts at 1 and monotonically decreases to 0.

>>> sc.gammaincc(0.5, [0, 1, 10, 100, 1000])
array([1.00000000e+00, 1.57299207e-01, 7.74421643e-06, 2.08848758e-45,
       0.00000000e+00])

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

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