jax.scipy.special.gamma

Contents

jax.scipy.special.gamma#

jax.scipy.special.gamma(x)[source]#

The gamma function.

JAX implementation of scipy.special.gamma.

The gamma function is defined for \(\Re(z)>0\) as

\[\mathrm{gamma}(z) = \Gamma(z) = \int_0^\infty t^{z-1}e^{-t}\mathrm{d}t\]

and is extended by analytic continuation to arbitrary complex values z. For positive integers n, the gamma function is related to the factorial() function via the following identity:

\[\Gamma(n) = (n - 1)!\]

For real inputs:

  • if \(x = -\infty\), NaN is returned.

  • if \(x = \pm 0\), \(\pm \infty\) is returned.

  • if \(x\) is a negative integer, NaN is returned. The sign of gamma at a negative integer depends on from which side the pole is approached.

  • if \(x = \infty\), \(\infty\) is returned.

  • if \(x\) is NaN, NaN is returned.

For complex inputs:

  • at non-positive integers (poles), nan+nanj is returned, matching SciPy.

  • if either real or imaginary component is NaN, nan+nanj is returned.

Parameters:

x (ArrayLike) – arraylike, real or complex valued. Complex inputs use a Lanczos approximation with reflection formula.

Returns:

array containing the values of the gamma function. For complex inputs, the output is complex-valued.

Return type:

Array

See also

Notes

For complex inputs, the implementation uses the Lanczos approximation (g=7, N=9 coefficients) with the reflection formula for Re(z) < 0.5.