[SciPy-dev] Definition of gammaln(x) for negative x
David Cournapeau
david@ar.media.kyoto-u.ac...
Sat Nov 1 12:05:17 CDT 2008
G-J van Rooyen wrote:
> Hey everyone
>
> Ticket #737 refers:
>
> -----
>
> Gamma in negative for negative x whose floor value is odd. As such,
> gammaln does not make sense for those values (while staying in the
> real domain, at least). scipy.special.gammaln returns bogus values:
>
> import numpy as np
> from scipy.special import gamma, gammaln
> print np.log(gamma(-0.5))
> print gammaln(-0.5)
>
> Returns nan in the first case (expected) and 1.26551212348 in the
> second (totally meaningless value).
>
> -----
>
> The info line for gammaln reads:
> * gammaln -- Log of the absolute value of the gamma function.
>
> With this definition of gammaln, the function actually works fine,
> since np.log(abs(gamma(-0.5))) is in fact 1.2655.
I have just checked with R, R does define log gamma as the
log(abs(gamma(x))) (I guess that's where the definition comes from). I
find this definition a bit strange, that's not the one I have seen where
I see it used, but I certainly don't claim to use what would be
considered as a reference for this stuff (I mostly use log gamma to deal
with precision problem of gamma in some statistics computation).
cheers,
David
More information about the Scipy-dev
mailing list