Understanding the confidence interval for a proportion — concept and principle
When you observe k "successes" in n trials (say, 45 of 120 customers said yes), the sample proportion p̂ = k/n estimates the true rate. A confidence interval shows how far that true rate could plausibly be from p̂. The calculator gives the classic Wald interval and the Wilson score interval, which statisticians recommend for most practical work.
How it is calculated
- Sample proportion: p̂ = k ÷ n.
- Critical value: z* from the standard normal distribution (1.96 for 95%).
- Wald: p̂ ± z* × √[p̂(1 − p̂) ÷ n].
- Wilson: centre = (p̂ + z*²/2n) ÷ (1 + z*²/n); half-width = z* × √[p̂(1 − p̂)/n + z*²/4n²] ÷ (1 + z*²/n); interval = centre ± half-width.
Results are proportions between 0 and 1; multiply by 100 for percentages.
The principle
The Wald interval plugs the estimate p̂ into the standard error, which works poorly when n is small or p̂ is near 0 or 1: it can extend below 0 or above 1, and its real coverage often falls well short of 95%. Wilson (1927) instead asks which values of p would not be rejected by a z-test given the data, and solves that inequality for p. The result is pulled slightly toward 0.5 and always stays within 0 to 1. Brown, Cai and DasGupta (2001) showed that its coverage is much closer to the nominal level.
Worked example
- Inputs: k = 45, n = 120, confidence 95%, so z* = 1.959964.
- p̂ = 45 ÷ 120 = 0.375.
- Wald: SE = √(0.375 × 0.625 ÷ 120) = 0.0441942; margin = 1.959964 × 0.0441942 = 0.0866190; interval 0.288381011 – 0.461618989.
- Wilson: z*²/n = 0.0320122, so the denominator is 1.0320122; centre = (0.375 + 0.0160061) ÷ 1.0320122 = 0.3788774.
- Half-width = 1.959964 × √(0.00195313 + 0.00006669) ÷ 1.0320122 = 0.0853531.
- Wilson interval: 0.2935242979 – 0.4642304937.
How to read the result
With 95% confidence the true rate lies roughly between 29% and 46%. The Wilson interval is shifted slightly toward 50% compared with Wald; with n = 120 and p̂ = 0.375 the two are close, but they diverge sharply for small samples or rates near 0% or 100%. To narrow the interval, increase n: the width shrinks in proportion to 1/√n.
Common mistakes
- Using Wald when k is 0 or n is tiny, which can yield an interval of width zero or below 0.
- Treating responses that are not independent (repeat customers, clustered samples) as n separate trials.
Frequently asked questions
What if I observe 0 successes?
Wald gives 0 – 0, which is useless. Wilson still gives a sensible upper limit; for 0 out of n, a quick approximation of the 95% upper bound is 3/n (the "rule of three").
Is there an exact interval?
Yes, the Clopper–Pearson interval is based on the binomial distribution; it is conservative, usually wider than Wilson.
Which interval should I report?
Wilson is a good default for most uses; state which method you used.
Sources: Wilson, E. B. (1927). Probable inference, the law of succession, and statistical inference. Journal of the American Statistical Association, 22, 209–212. · Brown, L. D., Cai, T. T. & DasGupta, A. (2001). Interval estimation for a binomial proportion. Statistical Science, 16(2), 101–133.