Incomplete gamma function in python?

scipy.special.gammainccannot take negative values ​​for the first argument. Are there any other implementations that can run in python? I can do manual integration for sure, but I would like to know if there are good alternatives that already exist.

Correct result: 1 - Gamma[-1,1] = 0.85

Use Scipy: scipy.special.gammainc(-1, 1) = 0

Thank.

+5
source share
2 answers

I usually need mpmath when I need special functions, and I'm not too concerned about performance. (Although its performance is pretty good in many cases).

For instance:

>>> import mpmath
>>> mpmath.gammainc(-1,1)
mpf('0.14849550677592205')
>>> 1-mpmath.gammainc(-1,1)
mpf('0.85150449322407795')
>>> mpmath.mp.dps = 50 # arbitrary precision!
>>> 1-mpmath.gammainc(-1,1)
mpf('0.85150449322407795208164000529866078158523616237514084')
+3
source

, , a < 0. http://en.wikipedia.org/wiki/Incomplete_gamma_function#Properties

, scipy- gammainc gammaincc Gamma (a, x)/Gamma (a)

+2

All Articles