I am trying to re-implement a binomial test initialy developed in R
with Python
. However, I am not sure if I am using the right functionality.
In R
, I get:
> binom.test (2, 8, 11/2364, alternative = "greater")
0.25
With Python
& SciPy
, I use
from scipy.stats import binom
binom.sf(2, 8, float(11)/float(2364))
5.5441613055814931e-06
In fact I have to do binom.sf(2, 8, float(11)/float(2364))
to make sure the third parameter is not 0
because of int division.
Why do the values differ? Do I have to specify the moments for Scipy / binom.sf
?
Should I use some other library?
scipy
hasscipy.stats.binom_test
, so no need to use the survival function. To get the same results withbinom.sf
you needbinom.sf(1, 8, float(11)/float(2364))
as you want to include the probability of 2.