Search code examples
pythonnormal-distributionbinomial-coefficients

Cumulative binomial distribution for large numbers


I have the following function implemented in python:

# Calculation of cumulative binomial distribution
def PDP(p, N, min):
    pdp=0
    for k in range(min, N+1):
        pdp += (float(factorial(N))/(factorial(k)*factorial(N-k)))*(p**k)*((1-p)**(N-k))
    return pdp

However, calculations produce too large values with a high n (up to 255). I have searched for approximations to these values, but to no avail. How would you go about this?


Solution

  • Suppose X follows binomial distribution,

    and you want to compute P(X >= m), I would first do a continuity correction so approximate by P(X >= m-0.5), and then I would approximate it using normal approximation.

    P((X - np)/ sqrt(np(1-p)) >= (m-0.5-np)/sqrt(np(1-p)) 
    

    which is approximation

    P(Z >= (m-0.5-np)/sqrt(np(1-p)) 
    

    where Z is the standard normal distribution.

    References for such approximation.