scipy.special.rgamma#

scipy.special.rgamma(z, out=None) = <ufunc 'rgamma'>#

Reciprocal of the gamma function.

Defined as \(1 / \Gamma(z)\), where \(\Gamma\) is the gamma function. For more on the gamma function see gamma.

Parameters:
zarray_like

Real or complex valued input

outndarray, optional

Optional output array for the function results

Returns:
scalar or ndarray

Function results

See also

gamma, gammaln, loggamma

Notes

The gamma function has no zeros and has simple poles at nonpositive integers, so rgamma is an entire function with zeros at the nonpositive integers. See the discussion in [dlmf] for more details.

Array API Standard Support

rgamma 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

⚠️ no JIT

Dask

n/a

See Support for the array API standard for more information.

References

[dlmf]

Nist, Digital Library of Mathematical functions, https://dlmf.nist.gov/5.2#i

Examples

>>> import scipy.special as sc

It is the reciprocal of the gamma function.

>>> sc.rgamma([1, 2, 3, 4])
array([1.        , 1.        , 0.5       , 0.16666667])
>>> 1 / sc.gamma([1, 2, 3, 4])
array([1.        , 1.        , 0.5       , 0.16666667])

It is zero at nonpositive integers.

>>> sc.rgamma([0, -1, -2, -3])
array([0., 0., 0., 0.])

It rapidly underflows to zero along the positive real axis.

>>> sc.rgamma([10, 100, 179])
array([2.75573192e-006, 1.07151029e-156, 0.00000000e+000])