【发布时间】:2018-04-11 08:16:53
【问题描述】:
在 scipy (scipy.stats.ncx2, scipy.special.chndtr) 中的非中心卡方分布的实现对于非中心参数的大值是不准确的。例如。考虑
from scipy.stats import ncx2
print(ncx2.cdf(1200,2,1000))
print(ncx2.cdf(1500,2,1000))
print(ncx2.cdf(2000,2,1000))
print(ncx2.cdf(5000,2,1000))
产生
0.998604279948
0.999933004449
0.999933004449
0.999933004449
scipy 中的实现基于 Abramowitz 和 Stegun 的公式 26.4.25,Handbook of Mathematical Functions (1966) (见https://github.com/scipy/scipy/blob/master/scipy/special/cdflib/cdfchn.f)。
有更快、更准确的算法来实现这个功能,尤其是对于大的非中心性。例如,R 显然使用了 Ding (1992)(参见 http://stat.ethz.ch/R-manual/R-devel/library/stats/html/Chisquare.html)。我想知道是否有人知道替代实现是否可以作为标准 python 库的一部分?
【问题讨论】:
-
也许在 SciPy 跟踪器中打开一个问题是在 Python 科学堆栈中实现它的最佳机会。
-
好的,就这么做了。