A statistical function to calculate the probability of getting n successes out of N attempts in a mutually exclusive, dichotomous, independent, random function with the probability of p.

Well, that's a load of gibberish, isn't it? Allow me to explain:

This can be described mathematically by the following function:


           N!
P(n) = ---------- pn(1-p)N-n
       n!(N - n)!

      |_________|
           |
           |
           |
           |
  ------------------------------------------------
  | Side note: This is the binomial coefficient  |
  | of N and n, or "N choose n"                  |
  ------------------------------------------------

P(n) is the probability of achieving exactly n successes. p is the probability of success in one single case. N is the number of trials.

An example: If I flip a coin seven times, what is the probability that it will land heads up twice? This gives us the following values:
N = 7
n = 2
p = 0.5 (it's a 50/50 chance of heads/tails)
Insert these values into the function:

           7!
P(2) = ---------- 0.52(1-0.5)7-2 = 0.1640625
       2!(7 - 2)!

The probability is approximately 16%.

This function is often used to calculate the probability to achieve at least m successes in N tries. This can be done in the following way:

 N
---
\   P(ni)
/
---
i=m

In the previous example, if I had wanted to calculate the probability to achieve at least 5 heads up, here's the formula:

 7
---
\   P(ni) = P(5) + P(6) + P(7)
/
---
i=5

This will cause a distribution not entirely unlike the normal distribution (the gaussian distribution).