Model counts of successes with the binomial distribution and counts of events in an interval with the Poisson distribution.
Why this matters
Writing a PMF by hand works for a die. Real problems have thousands of possible values: the number of defective chips in a lot of 5,000, the number of support tickets in an hour, the number of mutations in a stretch of DNA. Most of these follow a small set of named distributions with known formulas. If you can recognise which one fits, you get the probabilities, mean and variance for free.
The binomial distribution
Use the binomial when all of these hold:
- A fixed number of trials,
n. - Each trial is a success or a failure.
- Every trial has the same success probability,
p. - Trials are independent.
Then X = number of successes has
P(X = k) = C(n, k) * p^k * (1 - p)^(n - k) k = 0, 1, ..., n
E[X] = n p Var(X) = n p (1 - p)
C(n, k) ("n choose k") counts the ways to place k successes among n trials. In Python it is math.comb(n, k).
Worked example: defects
A machine makes parts with a 2% defect rate. In a sample of 50 parts:
P(no defects) = 0.98^50 ≈ 0.364
P(at most 2) = P(0) + P(1) + P(2) ≈ 0.922
E[X] = 50 * 0.02 = 1 defect SD = sqrt(50 * 0.02 * 0.98) ≈ 0.99
So about one batch in three has no defects at all, and a sample with 4 or more defects (probability about 1.8%) is a strong signal that the process has drifted. This is how acceptance sampling and lab QC limits are set.
from math import comb
def binomial_pmf(k, n, p):
return comb(n, k) * p**k * (1 - p) ** (n - k)
print(sum(binomial_pmf(k, 50, 0.02) for k in range(3))) # 0.9216
The Poisson distribution
Use the Poisson for counts of events in a fixed interval of time, space or volume when events happen independently at a steady average rate λ (lambda): calls per hour, typos per page, bacterial colonies per plate, photons per detector window.
P(X = k) = e^(-λ) * λ^k / k! k = 0, 1, 2, ... (no upper limit)
E[X] = λ Var(X) = λ
Worked example: a help desk
Calls arrive at an average of 3 per hour.
P(no calls in an hour) = e^-3 ≈ 0.050
P(at most 4 calls) = P(0) + ... + P(4) ≈ 0.815
P(5 or more calls) = 1 - 0.815 ≈ 0.185
If one person can handle 4 calls an hour, they will be overloaded in roughly one hour out of five. That is a staffing decision made with one formula.
Rates scale with the interval: 3 calls per hour means λ = 1.5 for a half-hour window and λ = 24 for an 8-hour shift.
Poisson as a binomial limit
When n is large and p is small, a binomial is almost exactly Poisson with λ = n p. For n = 1000 and p = 0.002, P(X = 2) is 0.2709 from the binomial and 0.2707 from the Poisson with λ = 2. This is why rare-event counts (claims, failures, mutations) are so often modelled as Poisson.
A check you can always run
Mean equals variance for a Poisson. If your count data has a variance much larger than its mean (common with web traffic and insurance claims), the data is overdispersed and a plain Poisson model will understate risk. Analysts then reach for the negative binomial distribution, which you will meet in regression courses.
Other discrete distributions to know by name
- Bernoulli: a single trial (binomial with
n = 1). - Geometric: number of trials until the first success; mean
1/p. - Negative binomial: trials until the
r-th success, or overdispersed counts. - Hypergeometric: successes when sampling without replacement from a small finite lot.
In libraries
numpy draws samples (rng.binomial(50, 0.02, size=1000), rng.poisson(3, size=1000)), and scipy.stats gives exact values (scipy.stats.binom.pmf(2, 50, 0.02), scipy.stats.poisson.cdf(4, 3)). Knowing the formulas lets you sanity-check both.
Common mistakes
- Using the binomial without independence or a constant p. Drawing 10 cards from a deck without replacement is hypergeometric, not binomial.
- Forgetting to rescale λ. A rate per hour does not apply directly to a 15-minute window.
- "At least" errors.
P(X ≥ 5) = 1 - P(X ≤ 4), not1 - P(X ≤ 5). - Assuming Poisson because the data is a count. Check that the variance is close to the mean.
Recap
- Binomial: fixed
nindependent yes/no trials with constantp; meannp, variancenp(1-p). - Poisson: counts in an interval at rate
λ; mean and variance bothλ. - Large
n, smallp: binomial ≈ Poisson withλ = np.
Try it
In the Do tab, write the Poisson PMF and CDF and use them to answer a staffing question.