【发布时间】:2017-11-09 16:25:45
【问题描述】:
我正在尝试使用Python 重新实现最初在R 中开发的二项式检验。但是,我不确定我是否使用了正确的功能。
在R,我得到:
> binom.test (2, 8, 11/2364, alternative = "greater")
0.25
对于Python & SciPy,我使用
from scipy.stats import binom
binom.sf(2, 8, float(11)/float(2364))
5.5441613055814931e-06
实际上我必须做binom.sf(2, 8, float(11)/float(2364)) 来确保第三个参数不是0 因为int 除法。
为什么这些值不同?我必须指定 Scipy / binom.sf 的时刻吗?
我应该使用其他库吗?
【问题讨论】:
-
scipy有scipy.stats.binom_test,所以不需要使用生存功能。要获得与binom.sf相同的结果,您需要binom.sf(1, 8, float(11)/float(2364)),因为您想包含 2 的概率。 -
0 是草稿中未删除的行,抱歉...
标签: python r scipy binomial-cdf