Learning outcomes
By the end of this lesson you should be able to: recognise the binomial setting and compute binomial probabilities; state the mean and standard deviation of a binomial random variable; convert any normal value to a z-score and read its percentile; and apply the 68-95-99.7 rule to a normal distribution.
Prerequisites
Lessons 4 and 5 (Probability rules, Random variables & expectation). You need expected value and variance, because each distribution here is summarised by its mean and standard deviation, and lesson 3 for what those summaries mean.
The big idea
Almost every probability calculation in applied work is a binomial calculation, a normal calculation, or something the two can approximate. The reason is structural: successes counted over repeated trials give a binomial, and averages or sums of many small independent contributions give a normal. Learn these two and you have a toolkit covering a very large share of real questions — from 'how many of these 20 patients respond?' to 'how extreme is this lab value?'.
The binomial setting and its summaries
Before computing anything, check four conditions. The number of trials n is fixed; every trial has the same success probability p; the trials are independent; and the variable counts successes. Fail any one of them and the binomial formula is the wrong tool — drawing balls from a bag without replacement, for instance, changes p on every draw.
When the setting holds, the probability of exactly k successes is the binomial formula: n choose k times p to the power k times (1 - p) to the power n - k. The factor n choose k counts the arrangements of k successes among n trials, p to the k weights the successes, and (1 - p) to the n - k weights the failures. The mean and variance follow from the expectation rules of lesson 5: each trial pays 1 with probability p, so E(X) = np and Var(X) = np(1 - p), with the standard deviation as its square root.
| Quantity | Binomial(n, p) | How to compute it |
|---|---|---|
| Mean | np | Sum of n trial means of p each |
| Variance | np(1 - p) | Sum of n independent trial variances |
| Standard deviation | sqrt(np(1 - p)) | Square root of the variance |
| P(X = k) | C(n, k) p^k (1-p)^(n-k) | Arrangements times weights |
| P(X <= k) | Sum of the above for 0..k | Discrete cumulative probability |
Worked example 1: binomial counts, mean and SD
A drug works on 30% of patients. Of 20 treated, how many responses are expected, what is the spread, and what is the chance of exactly 5 responses?
import math
n, p = 20, 0.3
mean = n * p
var = n * p * (1 - p)
print("mean (np):", round(mean, 4))
print("variance np(1-p):", round(var, 4))
print("SD:", round(math.sqrt(var), 4))
print("P(X = 5):", round(math.comb(n, 5) * p ** 5 * (1 - p) ** (n - 5), 4))
print("P(X <= 5):", round(sum(math.comb(n, k) * p ** k * (1 - p) ** (n - k) for k in range(6)), 4))mean (np): 6.0
variance np(1-p): 4.2
SD: 2.0494
P(X = 5): 0.1789
P(X <= 5): 0.4164Method: the mean is np = 20 x 0.3 = 6. The variance is np(1 - p) = 20 x 0.3 x 0.7 = 4.2, so the standard deviation is the square root of 4.2, about 2.0494. For the exact probability, C(20, 5) = 15504 arrangements each carry weight 0.3 to the fifth times 0.7 to the fifteenth, giving 0.1789. The cumulative probability P(X <= 5) sums the terms for k = 0 through 5 and comes to 0.4164, so there is a better-than-even chance of five or fewer responders.
Worked example 2: z-scores and the standard normal
Exam scores are roughly Normal(100, 15). Converting to z-scores makes every question a question about the one standard normal distribution.
import math
mu, sigma = 100, 15
for x in [85, 100, 115, 130]:
z = (x - mu) / sigma
pct = 100 * (0.5 * (1 + math.erf(z / math.sqrt(2))))
print(f"x = {x}: z = {z:.2f}, percent of values below = {pct:.2f}")x = 85: z = -1.00, percent of values below = 15.87
x = 100: z = 0.00, percent of values below = 50.00
x = 115: z = 1.00, percent of values below = 84.13
x = 130: z = 2.00, percent of values below = 97.72Method: z = (x - 100) / 15, so 85 gives -1, 100 gives 0, 115 gives +1 and 130 gives +2. The area under the standard normal curve below a z-score is the percentile, computed here from the error function: below z = -1 lies 15.87%, below z = 0 lies 50%, below z = 1 lies 84.13% and below z = 2 lies 97.72%. The complement gives the upper tail — only 2.28% of values exceed 130.
Those numbers are the 68-95-99.7 rule read backward: about 68% of values lie within 1 SD of the mean, 95% within 2 SDs and 99.7% within 3 SDs. The rule holds for every normal distribution regardless of its mean and SD, because the z-score has already absorbed them.
Worked example 3: the normal approximation to the binomial
Binomial probabilities with large n are tedious to sum, and the normal curve approximates them well once at least 10 successes and 10 failures are expected. The drug example has np = 6, which fails that check, so the approximation is shown anyway to expose the error it makes and to demonstrate the continuity correction that keeps it honest.
import math
n, p = 20, 0.3
mean, sd = n * p, math.sqrt(n * p * (1 - p))
z = (8.5 - mean) / sd
approx = 0.5 * (1 + math.erf(z / math.sqrt(2)))
exact = sum(math.comb(n, k) * p ** k * (1 - p) ** (n - k) for k in range(9))
print("mean:", round(mean, 2), "SD:", round(sd, 4))
print("z with the continuity correction (8.5):", round(z, 4))
print("P(X <= 8), normal approximation:", round(approx, 4))
print("P(X <= 8), exact binomial:", round(exact, 4))mean: 6.0 SD: 2.0494
z with the continuity correction (8.5): 1.2199
P(X <= 8), normal approximation: 0.8887
P(X <= 8), exact binomial: 0.8867Method: a binomial variable is discrete, so '8 or fewer' means all integers up to and including 8, and the boundary at 8.5 is the continuity correction that stops the continuous curve cutting the last block in half. The z-score is (8.5 - 6) / 2.0494 = 1.2199, whose standard normal area is 0.8887 against an exact binomial value of 0.8867. For larger n the agreement improves, but the gate is the success-failure condition: here np = 6 and n(1 - p) = 14, and since 6 is below 10, the normal model is not trusted for this problem.
Common mistakes
Watch outUsing the binomial when p changes between trials. Sampling without replacement, learning effects and time trends all break the fixed-p and independence assumptions; the binomial formula is then invalid, not merely approximate.
Watch outConfusing np with np(1 - p). The mean is np; the variance is np(1 - p). Reporting 4.2 as the mean of the drug example is a factor-of-1.4 error that changes every conclusion that follows.
Watch outTreating a z-score as a probability. A z-score of 2 is a distance, not a chance; the 97.72% comes from an area under the curve, which is a separate computation.
Watch outSkipping the success-failure check before the normal approximation. It requires at least 10 expected successes and 10 expected failures; without that, compute the exact binomial and do not approximate.
Check your understanding
A fair coin is flipped 10 times. What are the mean and standard deviation of the number of heads?
Test scores are Normal(100, 15). What is the probability of scoring above 130?
Why does the continuity correction use 8.5 rather than 8 when approximating P(X <= 8)?
Multiple choice
X ~ Binomial(20, 0.3). What are the mean and standard deviation?
For a Normal(100, 15) variable, which value has a z-score of -1.33?
According to the 68-95-99.7 rule, about what percentage of a normal distribution lies more than 2 standard deviations from its mean?
Which condition is required before the normal curve may approximate a binomial count?
X ~ Binomial(20, 0.3). What is P(X = 5)?
Summary and next
The binomial distribution, for a fixed number of independent trials with a common success probability, has mean np, variance np(1 - p), and a probability for exactly k successes given by the binomial formula. The normal distribution is symmetric and fully described by its mean and standard deviation, and z = (x - mu) / sigma converts any normal value into a percentile through the 68-95-99.7 rule or an area table. When at least 10 successes and 10 failures are expected, the binomial can be approximated by a normal curve with a continuity correction.
Next: sampling distributions and the Central Limit Theorem. Everything so far has described a process. Inference asks about a population mean from a sample, and the tool that makes that possible is the sampling distribution of the sample mean — which the normal distribution will turn into every confidence interval and test from here to the end of the course.