pythonscipygamma-function

Upper Incomplete Gamma Function of order 0 in scipy


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.


Solution

  • 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')