scipy.special.log_gammainc#

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

Logarithm of the regularized lower incomplete gamma function.

Defined as

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

for \(a > 0\) and \(x \geq 0\). This function is more accurate than computing log(gammainc(a, x)) directly.

Parameters:
aarray_like

Positive real parameter.

xarray_like

Nonneg real argument.

outndarray, optional

Optional output array for the function values.

Returns:
scalar or ndarray

Values of the log of the regularized lower incomplete gamma function.

See also

gammainc

regularized lower incomplete gamma function

gammaincc

regularized upper incomplete gamma function

log_gammaincc

log of the regularized upper incomplete gamma function

Notes

This function wraps the lgamma_p routine from the Boost Math C++ library [1].

References

[1]

The Boost Developers. “Boost C++ Libraries”. https://www.boost.org/.

Examples

This function is useful when the naive computation log(gammainc(a, x)) underflows for small values.

>>> import numpy as np
>>> from scipy.special import log_gammainc, gammainc
>>> with np.errstate(divide='ignore'):
...    print(np.log(gammainc(500, 30)))
-inf
>>> log_gammainc(500, 30)
-940.6700276993504