Confidence Intervals

Statistical Inference & Applied Statistics

Chapter 3 · Confidence Intervals

Chapter 2 established that a point estimate always carries sampling error. A confidence interval is the direct, practical fix: instead of reporting a single number as if it were exact, report a range of plausible values, together with how confident that range actually is.

Building a Confidence Interval

Confidence interval formula
CI = point estimate ± (critical value × standard error)

The critical value (z*) comes straight from Probability & Statistics Fundamentals' own standard normal distribution — how many standard errors wide the interval needs to be to capture the stated percentage of the sampling distribution:

Confidence levelCritical value (z*)
90%1.645
95%1.960
99%2.576

Worked Example: The Response-Time Sample, Revisited

Reusing Chapter 2's own sample: n = 25 requests, sample mean x̄ = 204ms, σ = 30ms (still assumed known here — Chapter 5's own t-test covers the more realistic case where σ itself must be estimated). Standard error: SE = 30/√25 = 6ms.

Confidence levelIntervalWidth
90%[194.13, 213.87]19.74ms
95%[192.24, 215.76]23.52ms
99%[188.54, 219.46]30.91ms
The confidence-vs-width tradeoff
Higher confidence needs a wider net — a 99% interval is genuinely wider than a 90% one, because casting a narrower net risks missing the true value more often. There's no free lunch: more certainty always costs precision, and the choice of confidence level is a real decision about which tradeoff a given situation actually needs.

Width Shrinks With Sample Size

Reusing Chapter 2's own three sample sizes, at a fixed 95% confidence level:

nSE95% CI width
256.0ms23.52ms
1003.0ms11.76ms
9001.0ms3.92ms

More data doesn't change the confidence level — it tightens the interval at whatever confidence level was chosen, exactly Chapter 2's own σ/√n shrinkage, now made directly visible in the width of the reported range.

What a Confidence Interval Actually Means

The single most common misinterpretation in all of statistics
A 95% confidence interval does not mean "there's a 95% probability the true mean falls in this specific interval." The true population mean is a fixed, though unknown, number — it either is or isn't in this particular interval, with no probability attached to that once the interval is already computed. The correct interpretation: if this exact sampling-and-interval-building process were repeated many times, about 95% of the resulting intervals would contain the true mean. The 95% describes the reliability of the method across repeated use, not the odds for this one specific interval.

A Forward Note: Proportions

Everything above used a sample mean. Chapter 6's A/B testing material needs confidence intervals for a proportion instead — a conversion rate, not an average response time. The idea is identical; only the standard error formula changes, to SE = √(p(1−p)/n). The confidence interval itself still follows the exact same estimate ± z* × SE shape.

Confidence Intervals in Code

Z_CRITICAL = {90: 1.645, 95: 1.96, 99: 2.576} def confidence_interval(point_estimate, sigma, n, confidence=95): se = sigma / (n ** 0.5) z = Z_CRITICAL[confidence] margin = z * se return (point_estimate - margin, point_estimate + margin) print(confidence_interval(204, sigma=30, n=25, confidence=95)) # (192.24, 215.76) — matches the worked example print(confidence_interval(204, sigma=30, n=25, confidence=99)) # (188.54, 219.46) — wider, at higher confidence

Hands-On Exercises

Exercise 1

A sample of n = 16 gives a sample mean of 550, with a known σ = 48. Compute the standard error, then the 95% confidence interval.

📄 View solution
Exercise 2

Given a fixed standard error of SE = 10, compute the width of the confidence interval at the 90%, 95%, and 99% confidence levels, using this chapter's own critical values. Confirm the widths increase as confidence increases, matching this chapter's own confidence-vs-width tradeoff.

📄 View solution
Exercise 3

A teammate says "we're 95% confident the true average is between 190ms and 210ms, so there's a 95% chance the real value is in that range." Using this chapter's own correct interpretation, explain specifically what's wrong with the teammate's restatement, and give the statistically correct version of the claim.

📄 View solution

Chapter 3 Quick Reference

  • CI formula: point estimate ± (z* × SE), reusing Chapter 2's own standard error directly
  • Critical values: 90% → 1.645, 95% → 1.96, 99% → 2.576
  • Higher confidence requires a wider interval — the confidence-vs-width tradeoff, with no way around it
  • Interval width shrinks with sample size at any fixed confidence level, following Chapter 2's own σ/√n shrinkage exactly
  • A 95% CI means: if this method were repeated many times, ~95% of the resulting intervals would contain the true value — not "95% probability this specific interval contains it"
  • The same estimate ± z* × SE shape applies to proportions too, with SE = √(p(1−p)/n) — Chapter 6's own A/B testing material
  • Next chapter: Hypothesis testing fundamentals