Confidence interval for a proportion
When x of n people answer yes, or x of n units fail, the observed proportion p̂ = x ÷ n estimates the true proportion. A confidence interval gives the range of values compatible with the data. Several methods exist, and the textbook one is the least reliable.
The four methods
- Wald: p̂ ± z √(p̂(1 − p̂) ÷ n). Simple, but it covers the true value less often than claimed, especially for small n or proportions near 0 or 100%. It can even give bounds below 0 or above 100%.
- Wilson (score interval): centered on (p̂ + z²/2n) ÷ (1 + z²/n). It keeps close to its nominal coverage even for small samples and is the recommended default.
- Agresti–Coull: add z²/2 successes and z²/2 failures, then apply the Wald formula. With 95% confidence this is roughly “add two successes and two failures”. It is simple and works well.
- Clopper–Pearson (exact): based on the binomial distribution. It always covers the true value at least as often as stated, so it is conservative and somewhat wider. It is often required in regulatory or medical contexts.
Example
18 successes out of 50 trials, so p̂ = 36%, with 95% confidence:
| Method | Interval |
|---|---|
| Wilson | 24.1% to 49.9% |
| Clopper–Pearson | 22.9% to 50.8% |
| Agresti–Coull | 24.1% to 49.9% |
| Wald | 22.7% to 49.3% |
With 50 observations the methods are close. With 2 successes out of 20, they diverge sharply: Wald gives −3.1% to 23.1%, an impossible negative bound, while Wilson gives 2.8% to 30.1%.
Zero successes
If x = 0, Wald gives the meaningless interval 0 to 0. The exact upper bound is 1 − (α/2)^(1/n), and the “rule of three” approximates the one-sided 95% upper bound by 3 ÷ n. With 0 adverse events in 100 patients, the true rate could still be about 3%.
Interpreting the interval
A 95% interval means that the method, applied to many samples, captures the true proportion 95% of the time. It does not account for bias: a non-random sample, low response rates or leading questions can shift the estimate far more than the interval suggests.
Planning a survey
The width of the interval shrinks with √n: to halve the margin of error, you need four times as many respondents. For a margin of about ±3 points at 95% confidence around 50%, you need roughly 1,070 respondents. The margin of error and sample size calculators handle this planning step.