mars.tensor.special.loggamma¶
- mars.tensor.special.loggamma(x, **kwargs)[源代码]¶
Principal branch of the logarithm of the gamma function.
Defined to be \(\log(\Gamma(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.
- 参数
z (array-like) – Values in the complex plain at which to compute
loggamma
out (ndarray, optional) – Output array for computed values of
loggamma
- 返回
loggamma – Values of
loggamma
at z.- 返回类型
ndarray
提示
It is not generally true that \(\log\Gamma(z) = \log(\Gamma(z))\), though the real parts of the functions do agree. The benefit of not defining loggamma as \(\log(\Gamma(z))\) is that the latter function has a complicated branch cut structure whereas loggamma is analytic except for on the negative real axis.
The identities
\[\begin{split}\exp(\log\Gamma(z)) &= \Gamma(z) \\ \log\Gamma(z + 1) &= \log(z) + \log\Gamma(z)\end{split}\]make loggamma useful for working in complex logspace.
On the real line loggamma is related to gammaln via
exp(loggamma(x + 0j)) = gammasgn(x)*exp(gammaln(x))
, up to rounding error.The implementation here is based on [hare1997].
引用
- hare1997
D.E.G. Hare, Computing the Principal Branch of log-Gamma, Journal of Algorithms, Volume 25, Issue 2, November 1997, pages 221-236.