scipy.special.log_gammaincc#

scipy.special.log_gammaincc(a, x, out=None) = <wrapped_ufunc 'log_gammaincc'>#

Logarithm of the regularized upper incomplete gamma function.

Defined as

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

for \(a > 0\) and \(x \geq 0\). This function is more accurate than computing log(gammaincc(a, x)) directly when the survival function value is very small.

Parameters:
aarray_like

Positive real parameter.

xarray_like

Nonnegative real argument.

outndarray, optional

Optional output array for the function values.

Returns:
scalar or ndarray

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

See also

gammainc

regularized lower incomplete gamma function

gammaincc

regularized upper incomplete gamma function

log_gammainc

log of the regularized lower incomplete gamma function

Notes

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

Array API Standard Support

log_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 typically 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. log_gammaincc does not currently support out for the PyTorch backend.

See Array API coverage for more information.

References

[1]

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

Examples

>>> import numpy as np
>>> from scipy.special import log_gammaincc, gammaincc

For very small survival function values, log(gammaincc(a, x)) underflows to -inf while log_gammaincc retains precision:

>>> with np.errstate(divide='ignore'):
...     print(np.log(gammaincc(10, 1000.0)))
-inf
>>> log_gammaincc(10, 1000.0)
-950.622998370156