scipy.special.gammainc
不能爲第一個參數取負值。有沒有其他的實現可以在python中使用?我可以肯定地進行手動集成,但是我想知道是否有已經存在的好替代方案。python中不完整的gamma函數?
Correct result: 1 - Gamma[-1,1] = 0.85
Use Scipy: scipy.special.gammainc(-1, 1) = 0
謝謝。
scipy.special.gammainc
不能爲第一個參數取負值。有沒有其他的實現可以在python中使用?我可以肯定地進行手動集成,但是我想知道是否有已經存在的好替代方案。python中不完整的gamma函數?
Correct result: 1 - Gamma[-1,1] = 0.85
Use Scipy: scipy.special.gammainc(-1, 1) = 0
謝謝。
無論何時我需要特殊功能,我通常都會達到mpmath,而且我不太關心性能。 (雖然它在很多情況下表現不俗的反正。)
例如:
>>> 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')
我有同樣的問題,並最終使用該函數的遞推關係時 http://en.wikipedia.org/wiki/Incomplete_gamma_function#Properties
還要注意的是SciPy的功能gammainc和gammaincc給正規化形式伽瑪(A,X)/伽瑪(一)
感謝,我做了一個簡單的網上搜索,但未能找到一個獨立的解決方案。猜猜這是爲單個功能安裝額外軟件包的少數情況之一;-) – nye17
'mpf'代表什麼? – LuizAngioletti