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

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])