06-02: Binomial and Poisson Distributions¶
Rather than build a probability table by hand every time, recognize the shape of the experiment and use its formula. Four discrete distributions cover the overwhelming majority of introductory problems.
The Binomial Distribution¶
When it applies — all four conditions must hold¶
1. A fixed number of trials, n
2. Each trial has exactly TWO outcomes: success / failure
3. The probability of success, p, is CONSTANT across trials
4. The trials are INDEPENDENT
If you sample without replacement from a small population, condition 4 fails — use the hypergeometric distribution instead (or the 5% rule: n ≤ 0.05N makes the binomial an acceptable approximation).
The formula¶
Reading it: nCx counts the arrangements of x successes among n trials; p^x q^(n−x) is the probability of any one such arrangement.
Mean, variance, standard deviation¶
Worked example¶
A drug is effective for 70% of patients. Ten patients are treated.
n = 10, p = 0.70, q = 0.30
P(exactly 8 work) = 10C8 (0.70)^8 (0.30)^2
= 45 × 0.05765 × 0.09
= 0.2335
P(at least 8) = P(8) + P(9) + P(10)
= 0.2335 + 0.1211 + 0.0282
= 0.3828
P(at most 7) = 1 − 0.3828 = 0.6172
μ = 10(0.70) = 7 patients
σ = √(10 × 0.70 × 0.30) = √2.1 = 1.449
Shape: the binomial is symmetric when p = 0.5, right-skewed when p < 0.5, left-skewed when p > 0.5. It becomes approximately normal when np ≥ 5 and nq ≥ 5 — the normal approximation of 07-02.
The Poisson Distribution¶
When it applies¶
Counts of events in a fixed interval of time, area, volume, or distance, when events occur independently at a constant average rate.
Examples: calls arriving per hour · typos per page · defects per m²
accidents per month · customers per 10 minutes
The formula¶
λ^x · e^(−λ)
P(X = x) = ──────────────────── x = 0, 1, 2, … (no upper limit)
x!
λ (lambda) = the mean number of events per interval, e ≈ 2.71828
Mean and variance — the signature property¶
The mean equals the variance. If your count data has a variance far above its mean, it is over-dispersed and Poisson is the wrong model.
Worked example¶
A help desk receives on average 3 calls per hour.
λ = 3
P(exactly 5 calls) = 3^5 · e^(−3) / 5! = 243 × 0.049787 / 120 = 0.1008
P(no calls) = 3^0 · e^(−3) / 0! = 0.0498
P(at most 2) = P(0)+P(1)+P(2) = 0.0498+0.1494+0.2240 = 0.4232
P(more than 2) = 1 − 0.4232 = 0.5768
μ = 3, σ = √3 = 1.732
Scaling the interval: λ is proportional to interval length. Average 3 calls/hour → in a 20-minute window, λ = 3 × (20/60) = 1.
Poisson as an approximation to the binomial¶
When n is large and p is small (n ≥ 100, np ≤ 10 is a common rule), the binomial is well approximated by a Poisson with λ = np.
The Geometric Distribution¶
The number of trials until the first success.
Example. P(sale) = 0.2 per call. P(first sale on the 4th call) = (0.8)³(0.2) = 0.1024. On average 1/0.2 = 5 calls per sale.
The Hypergeometric Distribution¶
Sampling without replacement from a finite population — the binomial's dependent cousin.
(aCx) · (bC(n−x))
P(X = x) = ─────────────────────────
(a+b)Cn
a = successes in the population, b = failures, n = sample size
Example. A box has 12 items, 4 defective. Draw 3 without replacement.
Choosing the Right Distribution¶
| Question shape | Distribution |
|---|---|
Fixed n trials, count successes, constant p, independent |
Binomial |
Count events in a fixed interval, rate λ |
Poisson |
| Trials until the first success | Geometric |
Fixed n drawn without replacement from a small finite population |
Hypergeometric |
Excel¶
' ── BINOMIAL ────────────────────────────────────────────────────────
=BINOM.DIST(8, 10, 0.7, FALSE) ' P(X = 8) exactly -> 0.23347
=BINOM.DIST(7, 10, 0.7, TRUE) ' P(X ≤ 7) cumulative-> 0.61722
=1-BINOM.DIST(7, 10, 0.7, TRUE) ' P(X ≥ 8) -> 0.38278
=BINOM.DIST.RANGE(10, 0.7, 8, 10) ' P(8 ≤ X ≤ 10) -> 0.38278
=BINOM.INV(10, 0.7, 0.95) ' smallest x with P(X≤x) ≥ 0.95 -> 9
=10*0.7 ' μ = np -> 7
=SQRT(10*0.7*0.3) ' σ = √npq -> 1.4491
=COMBIN(10,8)*0.7^8*0.3^2 ' the formula spelled out -> 0.23347
' ── POISSON ─────────────────────────────────────────────────────────
=POISSON.DIST(5, 3, FALSE) ' P(X = 5) -> 0.10082
=POISSON.DIST(2, 3, TRUE) ' P(X ≤ 2) -> 0.42319
=1-POISSON.DIST(2, 3, TRUE) ' P(X > 2) -> 0.57681
=3^5*EXP(-3)/FACT(5) ' the formula spelled out -> 0.10082
=SQRT(3) ' σ = √λ -> 1.7321
' Scale the interval: 3/hour over 20 minutes
=POISSON.DIST(0, 3*(20/60), FALSE) ' P(no calls in 20 min) -> 0.36788
' ── GEOMETRIC (no built-in — use the formula) ───────────────────────
=0.8^(4-1)*0.2 ' P(first success on trial 4) -> 0.1024
=1-0.8^4 ' P(success within 4 trials) -> 0.5904
=1/0.2 ' μ = 1/p -> 5
' ── HYPERGEOMETRIC ──────────────────────────────────────────────────
=HYPGEOM.DIST(1, 3, 4, 12, FALSE) ' x, n, successes in pop, pop size
' P(exactly 1 defective) -> 0.50909
=HYPGEOM.DIST(1, 3, 4, 12, TRUE) ' P(X ≤ 1) -> 0.76364
' ── Build a full distribution table ─────────────────────────────────
' Put x = 0..10 in A2:A12, then fill:
=BINOM.DIST(A2, $B$1, $B$2, FALSE) ' P(x)
=SUMPRODUCT($A$2:$A$12, B2:B12) ' μ, as a check against np
' Select A2:B12 ▸ Insert ▸ Column chart → probability histogram
R¶
# ── BINOMIAL: dbinom / pbinom / qbinom / rbinom ───────────────────
dbinom(8, size = 10, prob = 0.7) # P(X = 8) -> 0.2334744
pbinom(7, 10, 0.7) # P(X ≤ 7) -> 0.6172172
1 - pbinom(7, 10, 0.7) # P(X ≥ 8) -> 0.3827828
pbinom(7, 10, 0.7, lower.tail = FALSE) # same, no rounding loss
sum(dbinom(8:10, 10, 0.7)) # same, by summation
qbinom(0.95, 10, 0.7) # quantile -> 9
rbinom(20, 10, 0.7) # 20 random draws
c(mean = 10 * 0.7, sd = sqrt(10 * 0.7 * 0.3)) # 7, 1.4491
# Full distribution + histogram
x <- 0:10
px <- dbinom(x, 10, 0.7)
round(data.frame(x, px, cum = pbinom(x, 10, 0.7)), 5)
barplot(px, names.arg = x, col = "#5B2A86", border = NA,
xlab = "Successes", ylab = "P(x)", main = "Binomial(10, 0.7)")
# ── POISSON: dpois / ppois / qpois / rpois ────────────────────────
dpois(5, lambda = 3) # P(X = 5) -> 0.1008188
ppois(2, 3) # P(X ≤ 2) -> 0.4231901
ppois(2, 3, lower.tail = FALSE) # P(X > 2) -> 0.5768099
dpois(0, lambda = 3 * 20/60) # 20-minute window -> 0.3678794
rpois(20, 3)
c(mean = 3, var = 3, sd = sqrt(3))
# ── GEOMETRIC — CAREFUL: R counts FAILURES before the first success ─
dgeom(3, prob = 0.2) # 3 failures then success = trial 4
# -> 0.1024
pgeom(3, 0.2) # P(success within 4 trials) -> 0.5904
1 / 0.2 # mean number of TRIALS -> 5
# ── HYPERGEOMETRIC ─────────────────────────────────────────────────
dhyper(x = 1, m = 4, n = 8, k = 3) # m = successes, n = failures, k = draws
# -> 0.5090909
phyper(1, 4, 8, 3) # P(X ≤ 1) -> 0.7636364
# ── Comparing shapes ───────────────────────────────────────────────
par(mfrow = c(1, 3))
barplot(dbinom(0:10, 10, 0.2), names.arg = 0:10, main = "p = 0.2 (right-skew)")
barplot(dbinom(0:10, 10, 0.5), names.arg = 0:10, main = "p = 0.5 (symmetric)")
barplot(dbinom(0:10, 10, 0.8), names.arg = 0:10, main = "p = 0.8 (left-skew)")
par(mfrow = c(1, 1))
Warning
R's dgeom(k, p) gives the probability of k failures before the first success, so "first success on trial 4" is dgeom(3, p). Python's scipy.stats.geom uses the trial-number convention: geom.pmf(4, p). Excel has no geometric function — use q^(x−1)·p. Three tools, three conventions; check before you trust a number.
Python¶
import numpy as np
from scipy import stats
# ── BINOMIAL ───────────────────────────────────────────────────────
stats.binom.pmf(8, n=10, p=0.7) # P(X = 8) -> 0.2334744
stats.binom.cdf(7, 10, 0.7) # P(X ≤ 7) -> 0.6172172
stats.binom.sf(7, 10, 0.7) # P(X > 7) -> 0.3827828 (survival)
stats.binom.pmf([8, 9, 10], 10, 0.7).sum() # same
stats.binom.ppf(0.95, 10, 0.7) # quantile -> 9.0
stats.binom.rvs(10, 0.7, size=20, random_state=1) # random draws
stats.binom.mean(10, 0.7), stats.binom.std(10, 0.7) # 7.0, 1.4491
# Full distribution
x = np.arange(0, 11)
px = stats.binom.pmf(x, 10, 0.7)
np.round(px, 5)
# ── POISSON ────────────────────────────────────────────────────────
stats.poisson.pmf(5, mu=3) # P(X = 5) -> 0.1008188
stats.poisson.cdf(2, 3) # P(X ≤ 2) -> 0.4231901
stats.poisson.sf(2, 3) # P(X > 2) -> 0.5768099
stats.poisson.pmf(0, mu=3 * 20/60) # 20-minute window -> 0.3678794
stats.poisson.mean(3), stats.poisson.var(3) # 3.0, 3.0
# ── GEOMETRIC (scipy counts TRIALS, unlike R) ─────────────────────
stats.geom.pmf(4, p=0.2) # first success on trial 4 -> 0.1024
stats.geom.cdf(4, 0.2) # within 4 trials -> 0.5904
stats.geom.mean(0.2) # 5.0
# ── HYPERGEOMETRIC (M = population, n = successes, N = draws) ─────
stats.hypergeom.pmf(1, M=12, n=4, N=3) # -> 0.5090909
stats.hypergeom.cdf(1, 12, 4, 3) # -> 0.7636364
# ── Plot the three shapes ──────────────────────────────────────────
import matplotlib.pyplot as plt
fig, axes = plt.subplots(1, 3, figsize=(12, 3), sharey=True)
for ax, p in zip(axes, [0.2, 0.5, 0.8]):
ax.bar(x, stats.binom.pmf(x, 10, p), color="#5B2A86")
ax.set_title(f"Binomial(10, {p})")
plt.tight_layout(); plt.show()
Quick Reference¶
| Distribution | Parameters | Excel | R | Python (scipy.stats) |
|---|---|---|---|---|
| Binomial PMF | n, p |
BINOM.DIST(x,n,p,FALSE) |
dbinom(x,n,p) |
binom.pmf(x,n,p) |
| Binomial CDF | n, p |
BINOM.DIST(x,n,p,TRUE) |
pbinom(x,n,p) |
binom.cdf(x,n,p) |
| Binomial range | n, p |
BINOM.DIST.RANGE(n,p,a,b) |
sum(dbinom(a:b,n,p)) |
binom.pmf(range).sum() |
| Poisson PMF | λ |
POISSON.DIST(x,λ,FALSE) |
dpois(x,λ) |
poisson.pmf(x,λ) |
| Poisson CDF | λ |
POISSON.DIST(x,λ,TRUE) |
ppois(x,λ) |
poisson.cdf(x,λ) |
| Geometric | p |
q^(x-1)*p |
dgeom(x-1, p) |
geom.pmf(x, p) |
| Hypergeometric | a, b, n |
HYPGEOM.DIST(x,n,a,N,FALSE) |
dhyper(x,m,n,k) |
hypergeom.pmf(x,M,n,N) |
| Distribution | Mean | Variance |
|---|---|---|
| Binomial | np |
npq |
| Poisson | λ |
λ |
| Geometric | 1/p |
q/p² |
| Hypergeometric | n·a/(a+b) |
n·(a/N)(b/N)·((N−n)/(N−1)) |
Common Mistakes¶
- Using the binomial when sampling without replacement from a small population — use the hypergeometric (or check
n ≤ 0.05N). - Reading "at least 8" as
BINOM.DIST(8, …, TRUE). That isP(X ≤ 8). "At least 8" is1 − P(X ≤ 7). - Forgetting to scale
λwhen the interval changes. - Mixing up
xandnin the Excel argument order (BINOM.DIST(x, n, p, cumulative)). - Applying Poisson to data whose variance is far larger than its mean.
- Assuming the geometric conventions match across R, Python, and the textbook. They do not.
Exercises: 06-02: Exercises — Binomial and Poisson Distributions
⬅️ Previous: 06-01: Random Variables and Expected Value ➡️ Next: 07-01: Continuous, Uniform and Exponential Distributions