This is documentation for an old release of SciPy (version 0.19.1). Read this page in the documentation of the latest stable release (version 1.15.1).
scipy.special.loggamma¶
-
scipy.special.
loggamma
(z, out=None) = <ufunc 'loggamma'>¶ Principal branch of the logarithm of the Gamma function.
Defined to be log(Γ(x)) for x>0 and extended to the complex plane by analytic continuation. The function has a single branch cut on the negative real axis.
New in version 0.18.0.
Parameters: z : array-like
Values in the complex plain at which to compute
loggamma
out : ndarray, optional
Output array for computed values of
loggamma
Returns: loggamma : ndarray
Values of
loggamma
at z.See also
Notes
It is not generally true that logΓ(z)=log(Γ(z)), though the real parts of the functions do agree. The benefit of not defining
loggamma
as log(Γ(z)) is that the latter function has a complicated branch cut structure whereasloggamma
is analytic except for on the negative real axis.The identities
exp(logΓ(z))=Γ(z)logΓ(z+1)=log(z)+logΓ(z)make
loggama
useful for working in complex logspace. However,loggamma
necessarily returns complex outputs for real inputs, so if you want to work only with real numbers usegammaln
. On the real line the two functions are related byexp(loggamma(x)) = gammasgn(x)*exp(gammaln(x))
, though in practice rounding errors will introduce small spurious imaginary components inexp(loggamma(x))
.The implementation here is based on [hare1997].
References
[hare1997] (1, 2) D.E.G. Hare, Computing the Principal Branch of log-Gamma, Journal of Algorithms, Volume 25, Issue 2, November 1997, pages 221-236.