Understanding the binomial distribution calculator — concept and principle
The binomial distribution gives the probability of getting exactly k successes in n independent trials when each trial succeeds with the same probability p. Typical uses: the number of heads in 10 coin flips, defective items in a batch, patients responding to a treatment, or free throws made out of a fixed number of attempts. The calculator gives P(X = k), the cumulative probabilities P(X ≤ k) and P(X ≥ k), and the mean and standard deviation.
How it is calculated
- P(X = k) = C(n, k)·pᵏ·(1 − p)ⁿ⁻ᵏ, where C(n, k) = n! ÷ (k!(n − k)!) is the number of ways to choose which k trials succeed.
- P(X ≤ k) = P(X = 0) + P(X = 1) + … + P(X = k).
- P(X ≥ k) = 1 − P(X ≤ k) + P(X = k), so that k itself is included.
- Mean = np, standard deviation = √(np(1 − p)).
The calculator works with logarithms of factorials so that large n does not overflow.
The principle
Any single sequence with k successes and n − k failures, such as SSFFF…, has probability pᵏ(1 − p)ⁿ⁻ᵏ because the trials are independent. Every arrangement of the k successes has the same probability, and there are C(n, k) of them, so the probabilities add up to C(n, k)pᵏ(1 − p)ⁿ⁻ᵏ. The conditions are fixed n, two outcomes per trial, constant p and independence.
Worked example
- Defaults: n = 10, p = 0.5, k = 3.
- C(10, 3) = 120 and 0.5³·0.5⁷ = 0.5¹⁰ = 1/1024.
- P(X = 3) = 120/1024 = 0.1171875.
- P(X ≤ 3) = (1 + 10 + 45 + 120)/1024 = 176/1024 = 0.171875.
- P(X ≥ 3) = 1 − (1 + 10 + 45)/1024 = 968/1024 = 0.9453125.
- Mean = 10 × 0.5 = 5, SD = √2.5 ≈ 1.58113883.
| Trials n | P(X = k) |
|---|---|
| 2.5 | 0.0552427173 |
| 5 | 0.3125 |
| 7.5 | 0.2468658928 |
| 10 | 0.1171875 |
| 12.5 | 0.0434281127 |
| 15 | 0.0138854981 |
| 20 | 0.0010871887 |
How to read the result
Most outcomes fall within about two standard deviations of the mean; here, from roughly 2 to 8 heads. A small P(X ≤ k) (for example below 0.05) says that so few successes would be unusual if p were really true, which is the idea behind a one-sided binomial test. When np and n(1 − p) are both at least about 10, the normal distribution is a good approximation.
Common mistakes
- Mixing up "at most" (≤) and "fewer than" (<): P(X < 3) = P(X ≤ 2).
- Using the binomial when drawing without replacement from a small group; that is hypergeometric.
- Forgetting that p must stay the same on every trial.
Frequently asked questions
How do I find "at least one success"?
P(X ≥ 1) = 1 − (1 − p)ⁿ.
What happens if n is large and p is small?
The binomial approaches the Poisson distribution with λ = np.
Is the distribution symmetric?
Only when p = 0.5. For p < 0.5 it is skewed to the right, for p > 0.5 to the left.
Sources: Sheldon M. Ross, A First Course in Probability, Pearson — binomial random variables · NIST/SEMATECH e-Handbook of Statistical Methods, section 1.3.6.6.18 Binomial Distribution