Samples and Confidence Intervals
A confidence interval is a range of values, computed from a random sample, that is built to contain the unknown population parameter with a stated long-run frequency, the confidence level; for a mean with known standard deviation σ it is x̄ ± z*·σ/√n. In brief: a sample of n = 36 with mean x̄ = 50 from a population with σ = 12 has the standard error 12/6 = 2, so the 95% confidence interval is 50 ± 1.96 · 2 = (46.08, 53.92).
Statistical inference uses a sample to say something about a whole population. This guide explains populations, samples and sampling distributions, the central limit theorem, and then builds confidence intervals for a mean (with σ known or estimated by the sample standard deviation) and for a proportion, including how to choose the sample size and how to interpret the result correctly, with worked examples and a table of critical values.
What are a population and a sample?
The population is the whole group of interest (all voters, all light bulbs from a factory), and a parameter is a fixed number describing it, such as the mean μ or the proportion p. A sample is a part of the population that is actually measured, and a statistic computed from it (the sample mean x̄, the sample proportion p̂) is used to estimate the parameter. A simple random sample gives every group of n members the same chance of selection, which avoids systematic bias. Convenience samples (the first people who answer a survey) can mislead, no matter how large they are.
What is the sampling distribution of the mean?
If you drew many samples of size n, their means would vary around μ with the standard deviation σ/√n, called the standard error. The central limit theorem states that for large n (a common rule of thumb is n ≥ 30) the distribution of x̄ is approximately normal, whatever the shape of the population, with mean μ and standard error σ/√n. Larger samples give smaller standard errors, but only at the rate 1/√n: to halve the error, one needs four times as many observations.
How do you build a confidence interval for a mean?
For a confidence level 1 − α, the interval is x̄ ± (critical value) × (standard error). If σ is known (or n is large), the critical value is the normal z*; if σ is estimated by the sample standard deviation s, one uses the Student t critical value with n − 1 degrees of freedom, which is larger for small samples, and the standard error is s/√n.
Example 1: σ known
n = 36, x̄ = 50, σ = 12. The standard error is 12/√36 = 2. For 95%, z* = 1.96, so the margin of error is 3.92 and the interval is (46.08, 53.92). For 99%, z* = 2.576 gives 50 ± 5.15 = (44.85, 55.15): a higher confidence level makes the interval wider.
Example 2: σ unknown, small sample
n = 10, x̄ = 20, s = 4. The standard error is 4/√10 ≈ 1.265. With 9 degrees of freedom, t* = 2.262 for 95%, so the margin is 2.862 and the interval is (17.14, 22.86). Using z* = 1.96 would give the narrower, overconfident interval (17.52, 22.48).
How do you build a confidence interval for a proportion?
For a sample proportion p̂ from n trials, the standard error is √(p̂(1 − p̂)/n) and the interval is p̂ ± z*√(p̂(1 − p̂)/n), valid when np̂ and n(1 − p̂) are both at least about 10.
Example 3: a poll
In a sample of 400 voters, 240 support a proposal. p̂ = 0.6, the standard error is √(0.6 · 0.4/400) = √0.0006 ≈ 0.0245, the margin of error at 95% is 1.96 · 0.0245 ≈ 0.048, and the interval is (0.552, 0.648), that is 55.2% to 64.8%.
How large must the sample be?
To achieve a margin of error E, solve z*σ/√n = E: n = (z*σ/E)2, rounded up. For a proportion with no prior estimate, use p̂ = 0.5, the worst case: n = (z*/E)2 · 0.25.
Example 4: planning a sample
To estimate a mean with σ = 12 to within ±3 at 95% confidence: n = (1.96 · 12/3)2 = 7.842 ≈ 61.5, so n = 62. To estimate a proportion to within ±3 percentage points: n = (1.96/0.03)2 · 0.25 ≈ 1067.1, so about 1068 respondents.
How should you interpret a confidence interval?
The 95% refers to the method: if we repeated the sampling many times and built an interval each time, about 95% of those intervals would contain the true parameter. For one computed interval, the parameter is either inside or not; it is not correct to say that “the probability is 95% that μ lies in (46.08, 53.92)” in the frequentist sense. The interval is not a range for individual observations, and it does not mean that 95% of the population lies inside it.
Table of critical values
| Confidence level | α | z* | t*, 9 df | t*, 29 df |
|---|---|---|---|---|
| 90% | 0.10 | 1.645 | 1.833 | 1.699 |
| 95% | 0.05 | 1.960 | 2.262 | 2.045 |
| 99% | 0.01 | 2.576 | 3.250 | 2.756 |
Where does the idea come from?
The central limit theorem goes back to de Moivre and Laplace in the eighteenth century. William Sealy Gosset, writing under the pseudonym “Student” in 1908, introduced the t distribution for small samples. Jerzy Neyman formulated confidence intervals in the 1930s as a way of stating the uncertainty of an estimate with a guaranteed long-run coverage.
Which mistakes are common?
Using z when σ is estimated from a small sample
With an estimated standard deviation and a small n, use the t value. Otherwise the interval is too narrow.
Mixing the standard deviation and the standard error
The standard error σ/√n describes the sample mean, not individual observations.
Believing that a bigger sample removes bias
A larger sample reduces random error only. A biased sampling method gives a biased interval, however large the sample.
Misreading the confidence level
The level is a property of the procedure, not the probability for one particular interval.