Binomial test in Python for very large numbers
Posted
by Morlock
on Stack Overflow
See other posts from Stack Overflow
or by Morlock
Published on 2010-06-16T18:38:08Z
Indexed on
2010/06/16
19:32 UTC
Read the original article
Hit count: 209
python
|binomial-coefficients
I need to do a binomial test in Python that allows calculation for 'n' numbers of the order of 10000.
I have implemented a quick binomial_test function using scipy.misc.comb, however, it is pretty much limited around n = 1000, I guess because it reaches the biggest representable number while computing factorials or the combinatorial itself. Here is my function:
from scipy.misc import comb
def binomial_test(n, k):
"""Calculate binomial probability
"""
p = comb(n, k) * 0.5**k * 0.5**(n-k)
return p
How could I use a native python (or numpy, scipy...) function in order to calculate that binomial probability? If possible, I need scipy 0.7.2 compatible code.
Many thanks!
© Stack Overflow or respective owner