Point estimates hide their own uncertainty
A single number estimate is a report without a confidence rating. The conversion rate is three point two percent â but from how many visitors? The mean delivery time is twenty-two minutes â from a day of data or a year? A confidence interval restores that missing dimension by giving a range of values that are all reasonably compatible with what you observed, together with a stated level of confidence in the procedure that produced the range. It converts "here is my guess" into "here is how precise my guess is, and what would change it."
The practical value shows up in decisions. An interval that excludes zero says an effect exists at the chosen level; an interval straddling zero says the data are compatible with no effect at all, which is a very different statement from proving there is no effect. An interval so wide that both a large gain and a large loss are inside it tells you the study was underpowered before anyone looks at a p-value. Reporting intervals also forces honesty about precision: the width of the interval is a direct measure of how much information the sample actually contained.
The recipe: estimate, critical value, standard error
Every classical confidence interval has the same anatomy. Take a point estimate, add and subtract a critical value drawn from a known reference distribution, and multiply by the standard error of the estimate. The point estimate supplies the centre, the standard error supplies the scale, and the critical value supplies the coverage level. Choosing the confidence level widens or narrows the interval without moving its centre, which is why ninety-nine percent intervals are always wider than ninety-five percent intervals computed from the same data.
The critical value is the piece that changes with the situation. When the population standard deviation is known, the standard normal distribution supplies it: one point six four five for ninety percent, one point nine six for ninety-five, two point five seven six for ninety-nine. When the standard deviation has to be estimated from the data â which is nearly always â the student's t distribution supplies it instead, and its heavier tails widen the interval to reflect the extra uncertainty. The penalty is severe for small samples and fades quickly: by thirty degrees of freedom the t values are within a few percent of the normal ones.
| Confidence level | Alpha | Normal critical value | t critical value at 30 degrees of freedom |
|---|---|---|---|
| 90 percent | 0.10 | 1.645 | 1.697 |
| 95 percent | 0.05 | 1.960 | 2.042 |
| 99 percent | 0.01 | 2.576 | 2.750 |
Means: when sigma is known and when it is not
For a mean with known population standard deviation, the interval is the sample mean plus or minus the normal critical value times sigma divided by the square root of n. In practice sigma is unknown and the sample standard deviation stands in, which switches the reference distribution to t with n minus one degrees of freedom. The resulting interval is exactly what a one-sample t test inverts: if the hypothesised value lies outside the interval, the corresponding two-sided test rejects at the same level.
The t interval assumes the underlying distribution is roughly normal, and that assumption matters most when the sample is small. With large samples the central limit theorem carries the interval regardless of shape, though strong skew still argues for working on a transformed scale or switching to a bootstrap. When observations come in matched pairs â before and after the same subject â the interval should be built on the within-pair differences, which usually removes a large source of variation and produces a much tighter and more powerful result than treating the two measurements as independent groups.
Proportions: why the Wald interval misbehaves
The textbook interval for a proportion adds and subtracts the normal critical value times the square root of p-hat times one minus p-hat over n. It is called the Wald interval, and it fails in exactly the situations where you most want an interval: small samples, and proportions near zero or one. When p-hat is zero, the Wald width collapses to zero, so the interval reports perfect certainty about a quantity you have barely measured.
The Wilson score interval fixes this by centre-shifting the estimate toward one half in proportion to the sample size, which keeps the interval inside the unit range and never collapses. Simulation studies show Wilson coverage close to nominal across the whole range, while Wald coverage can fall far below its stated level. The Agresti-Coull interval is a simpler approximation that adds two successes and two failures before computing, and it performs nearly as well. Rule of thumb: reach for Wilson by default and treat the Wald formula as a teaching device rather than a tool.
Width, sample size, and the cost of precision
The margin of error is the critical value times the standard error, and everything that shrinks the standard error shrinks the margin. More confident intervals are wider. More variable populations are wider. Larger samples are narrower, at the square root rate, which means the relationship between budget and precision is brutally non-linear. To go from a three-point margin to a one-and-a-half-point margin you must multiply the sample by four, not two.
Because the margin appears squared in the rearranged formula, planning a study is a direct calculation: choose the confidence level, estimate the variability from a pilot or prior work, decide the acceptable margin, and solve for n. For proportions the worst case is p-hat equals one half, which maximises the product p-hat times one minus p-hat; using one half gives a conservative sample that will not fall short. If the sampling fraction exceeds about five percent of a finite population, apply the finite population correction before finalising the budget.
Building intervals in Python
import numpy as np
from scipy import stats
def t_interval(data, confidence=0.95):
x = np.asarray(data, dtype=float)
n = x.size
mean = x.mean()
se = x.std(ddof=1) / np.sqrt(n)
crit = stats.t.ppf((1 + confidence) / 2, df=n - 1)
return mean - crit * se, mean + crit * se, mean, crit * se
def z_interval(mean, sigma, n, confidence=0.95):
crit = stats.norm.ppf((1 + confidence) / 2)
margin = crit * sigma / np.sqrt(n)
return mean - margin, mean + margin
def wilson_interval(successes, n, confidence=0.95):
z = stats.norm.ppf((1 + confidence) / 2)
p = successes / n
denom = 1 + z ** 2 / n
centre = (p + z ** 2 / (2 * n)) / denom
half = z * np.sqrt(p * (1 - p) / n + z ** 2 / (4 * n ** 2)) / denom
return centre - half, centre + half
response_times = np.array([212, 234, 198, 245, 221, 205, 256, 219, 233, 227,
241, 209, 248, 216, 238, 224, 203, 251, 230, 214])
lo, hi, m, moe = t_interval(response_times)
print(f"mean {m:.1f}, margin {moe:.1f}, 95% CI [{lo:.1f}, {hi:.1f}]")
print("Wilson, 3 successes in 20:", np.round(wilson_interval(3, 20), 4))
print("Wald, 3 successes in 20:",
np.round((3 / 20 - 1.96 * np.sqrt(0.15 * 0.85 / 20),
3 / 20 + 1.96 * np.sqrt(0.15 * 0.85 / 20)), 4))
Notice how much wider the Wilson interval is than the Wald one at fifteen percent with only twenty observations. That gap is not conservatism for its own sake; it is the difference between honest coverage and an interval that undercovers badly.
The second block shows the bootstrap alternative, which needs no distributional assumption and works for statistics that have no closed-form standard error.
import numpy as np
def bootstrap_interval(data, stat_fn=np.median, n_boot=10_000,
confidence=0.95, seed=0):
rng = np.random.default_rng(seed)
x = np.asarray(data, dtype=float)
n = x.size
stats_ = np.array([stat_fn(rng.choice(x, n, replace=True))
for _ in range(n_boot)])
alpha = (1 - confidence) / 2
return (np.percentile(stats_, 100 * alpha),
np.percentile(stats_, 100 * (1 - alpha)))
latency = np.array([18, 21, 24, 19, 67, 22, 20, 23, 45, 21,
19, 25, 22, 88, 20, 24, 21, 26, 23, 19])
print("median CI (bootstrap):",
np.round(bootstrap_interval(latency), 2))
print("median:", np.median(latency),
" mean:", round(float(np.mean(latency)), 2))
The bootstrap median interval is visibly asymmetric around the point estimate because a handful of large latencies pull the mean to the right while leaving the median where it was. A symmetric t interval built around the mean would misrepresent that shape entirely, which is precisely the case where resampling earns its keep.
Misreadings that invert the conclusion
Common Mistakes
Reading a 95 percent interval as having a 95 percent probability of containing the parameter
Fix: The parameter is fixed; 95 percent describes the long-run coverage of the procedure, not belief about this interval.
Treating an interval that includes zero as proof of no effect
Fix: Report the width: a wide interval means the study was imprecise, not that the effect is absent.
Using the Wald interval for small samples or extreme proportions
Fix: Use the Wilson score interval, which keeps coverage near nominal in exactly those regimes.
Building an interval on paired data as if the groups were independent
Fix: Compute within-pair differences first and intervalise those; the width usually shrinks dramatically.
Comparing groups by checking whether their intervals overlap
Fix: Run the direct test or build an interval for the difference; overlap of separate intervals is the wrong comparison.
Assuming a narrower interval is always better
Fix: Width reflects real variability; shrink it with more data, not by raising the confidence level's appearance.
Best Practices
- Report the point estimate, the interval, and the confidence level together in every result.
- Size the study from a target margin of error before collecting data.
- Prefer Wilson for proportions and t for means; reserve the normal formula for teaching.
- Check whether the interval supports a decision â does it exclude the null value or not?
- Use a bootstrap interval when the statistic has no closed-form variance or the shape is badly skewed.
Confidence intervals in brief
Where to go next
- Confidence Intervals for the Mean derives the z and t intervals with worked examples.
- Confidence Intervals for Proportions compares Wilson, Agresti-Coull, and Wald coverage.
- Margin of Error examines each factor that widens or narrows an interval.
- Sample Size Determination turns a target margin into a recruitment budget.