I am trying to implement the upper incomplete gamma function of order zero in Python. Normally we use gammaincc
function but according to the docs,it's defined only for positive a. Is there any way to implement it in python for a=0 case? Thanks.
Asked
Active
Viewed 448 times
2

Prav001
- 343
- 1
- 5
- 12
-
1No, because Gamma(0) diverges. There's good reason it's defined only for positive `a`. – Silver Nov 05 '18 at 03:18
-
I am not trying to implement regularized upper incomplete gamma function but the standard function which is not scaled by dividing it by Gamma(a). It definitely exists. See http://www.wolframalpha.com/input/?i=Gamma%5B0,+0.1%5D – Prav001 Nov 05 '18 at 06:20
1 Answers
4
SciPy implements the regularized incomplete gamma function, the one with division by Gamma(a). This division makes no sense when a=0, but the non-regularized upper gamma still makes sense. Unfortunately there is no flag like regularized=False
in SciPy.
However, in the special case a=0
the upper incomplete gamma function agrees with the exponential integral exp1
which is available in SciPy:
>>> from scipy.special import exp1
>>> exp1(1.3)
0.13545095784912914
(Compare to Wolfram Alpha).
Alternatively, the mpmath
library computes non-regularized incomplete gammas by default.
>>> import mpmath
>>> mpmath.gammainc(0, 1.3)
mpf('0.13545095784912914')
-
One can also use "expn(x)" if using minus sign twice looks cumbersome! – Prav001 Nov 05 '18 at 06:26
-