[SciPy-User] Question on scipy.special.gammaincc

Skipper Seabold jsseabold at gmail.com
Tue May 24 15:44:55 EDT 2011


On Tue, May 24, 2011 at 2:45 PM, Christoph Deil
<deil.christoph at googlemail.com> wrote:
> I want to use scipy to compute the incomplete gamma function for negative first arguments.
>
> Using www.wolframalpha.com I find
> 1 - Gamma[ 1,1] ---> 0.63
> 1 - Gamma[-1,1] ---> 0.85
>
> Using scipy 0.9 I find
> scipy.special.gammainc( 1, 1) ---> 0.63
> scipy.special.gammainc(-1, 1) ---> 0
>
> The same incorrect value 0 is returned for any negative first argument.
>
> Is this a bug?

This is because it returns the regularized incomplete gamma function
(see the doc string). It returns zero because Gamma(n) = inf for n <
0.

> Is there another way to compute the incomplete gamma function for negative first arguments?
>

I don't think scipy has a generalized incomplete gamma function
without the regularization. You might try mpmath

[~]
[1]: import mpmath

[~]
[2]: 1 - mpmath.gammainc(-1,1)
[2]: mpf('0.85150449322407795')

[~]
[3]: 1 - mpmath.gammainc(-1,1,regularized=True)
[3]: mpf('1.0')

Skipper



More information about the SciPy-User mailing list