【问题标题】:Is there a Python function equivalent to Gamma[a, z] in Mathematica?在 Mathematica 中是否有等效于 Gamma[a, z] 的 Python 函数?
【发布时间】:2020-04-28 15:28:51
【问题描述】:
我相信 Mathematica 中实现的不完全 Gamma 函数相当于上 gamma 函数的非正则化版本。在 scipy 中实现的 Gamma 不完全函数是正则化的下 gamma 函数。但是,据我所知,我可能是错的在这个领域是零。我需要在 Python 中计算 Mathematica 中不完全 gamma 函数的等价物
提前感谢您的所有帮助!
【问题讨论】:
标签:
python
math
wolfram-mathematica
【解决方案1】:
scipy.special 模块包含 lower incomplete gamma function scipy.special.gammainc 和 upper incomplete gamma function scipy.special.gammaincc 的实现(注意末尾的第二个 c)
scipy 给出了 Mathematicas 等效的缩放版本。如果Gamma[a, x] 中的 a>0,您应该可以使用:
from scipy.special import gamma, gammaincc
gamma(0.01)*(gammaincc(0.01, 1))
# 0.22036593781812577
相当于 Mathematica 中的 Gamma[0.01, 1]。