Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a Python function equivalent to Gamma[a, z] in Mathematica?

I believe the incomplete Gamma function implemented in Mathematica is equivalent to an unregularized version of the upper gamma function.. The Gamma incomplete function as implemented in scipy is a regularized lower gamma function.. However, I may be wrong as my knowledge in this area is zero. I need to compute an equivalent of the incomplete gamma function from Mathematica in Python

Thank you in advance for all the help!

like image 845
Prasanna Avatar asked Jun 19 '26 08:06

Prasanna


1 Answers

The scipy.special module contains an implementation of both the lower incomplete gamma function scipy.special.gammainc and the upper incomplete gamma function scipy.special.gammaincc (note the second c at the end)

scipy gives a scaled version of Mathematicas equivalent. If a>0 in Gamma[a, x] you should be able to use:

from scipy.special import gamma, gammaincc
gamma(0.01)*(gammaincc(0.01, 1))
# 0.22036593781812577

for the equivalent of Gamma[0.01, 1] in Mathematica.

enter image description here

like image 181
L_W Avatar answered Jun 20 '26 22:06

L_W



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!