When do you use the binomial distribution?
Use it to count successes in a fixed number of independent trials, each with the same probability of success. The probability of exactly k successes in n trials is C(n,k) p^k (1-p)^(n-k).
Explain it simply
Four checks make a situation binomial:
- A fixed number of trials, n.
- Each trial has two outcomes: success or failure.
- The chance of success, p, is the same each time.
- Trials are independent.
Guessing answers on a quiz fits well: each question is a trial and you either get it right or not.
Example
A 10-question quiz has 5 options per question, so a blind guess is right with p = 0.2. What is the chance of exactly 3 correct?
P = C(10,3) x 0.2^3 x 0.8^7 = 120 x 0.008 x 0.2097152 = 0.2013
from scipy.stats import binom
print(round(binom.pmf(3, 10, 0.2), 4)) # 0.2013
print(10 * 0.2) # 2.0 (expected correct answers)The mean is n x p = 2 and the variance is n x p x (1-p) = 1.6.
What to say in the interview
"Binomial models the number of successes in n independent yes/no trials with a constant success probability. Examples are clicks out of 1000 ad impressions or defective items in a batch. If the trial probability changes or trials are dependent, such as drawing without replacement from a small pool, binomial is only an approximation."
Common mistakes
- Using it when the number of trials is not fixed, for example counting events over a time window. That is a Poisson situation.