TactivergeLite

Lite / Engineering Complex Systems / Week 29

What a 95% confidence interval really promises

Your interval is 47.2 to 49.0 ms. Is there a 95% chance the true mean is in there?

About 45 min · 3 goals · Checked by automated tests · Full interactive version

Why should I care?

An interval is the most honest way to report a measured quantity: it says what you know and how well. This lesson builds the interval, then tests what '95%' means by running thousands of experiments in the browser.

Predict

You draw 20 experiments and build a 95% interval from each. How many intervals will miss the true mean?

  1. None: 95% intervals are reliable
  2. About 1, but it could easily be 0, 2 or 3
  3. Exactly 1, every time
  4. About 5
Guess first, then reveal

On average 5% of 20 = 1 interval misses, but which and how many varies from batch to batch. The 95% describes the long-run hit rate of the procedure, which is why a running tally over many batches settles near 95%.

Discover

Keep 95% and n = 30. Press 'Draw 20 more experiments' ten times and watch the running tally approach 95%. Then set n = 3 and reset: the tally falls short. Finally switch to 99% and watch the bars lengthen.

What the interactive shows (text version)

The simulator draws 20 experiments of n readings from a normal distribution with true mean 50 and builds a confidence interval from each, drawn as a horizontal bar. Bars that miss the true mean are marked 'miss'. Over many batches, about 95% of 95% intervals contain 50 when n is 30; with n = 3 coverage drops to roughly 80%, because z = 1.96 is too small when σ is estimated from so few points.

You can also open the interactive on the full site when you have a faster connection.

Watch (optional)

Watch for: Watch how the interval is built from many resampled means before any formula appears; it is the same idea as the simulator.

Builds the idea of a confidence interval from resampling before any formula, so the 95% stops sounding like magic.

“Confidence Intervals, Clearly Explained!!!” by StatQuest with Josh Starmer (opens YouTube; streaming video uses a lot of data)

The video is optional. Everything you need is in this lesson's text.

Understand

The recipe

  1. Compute x̄ and s from n independent measurements. 2. SE = s/√n. 3. Half-width h = z·SE. 4. Report x̄ ± h with the confidence level, n and the method. Example: 48.1 ± 0.9 ms (95% CI, n = 30, normal approximation).

The correct interpretation

If you repeated the whole experiment many times, about 95% of the intervals built this way would contain the true mean. Once your interval is computed, μ either is in it or isn't; you just don't know which. Saying 'there is a 95% probability μ lies between 47.2 and 49.0' is a common shortcut, but strictly it is a different (Bayesian) statement.

When the approximation breaks

The z-interval assumes independent data, a roughly normal sampling distribution and enough data to trust s. It under-covers for small n (use t), for strongly skewed data with small n (use more data, a transformation, or the bootstrap), and badly for correlated data such as drifting benchmarks. Systematic error is never captured: a mis-calibrated timer shifts every interval.

Width, level and effort

Higher confidence widens the interval (99% is about 31% wider than 95%). Quadrupling n halves it. Choose the level before you look at the data, and plan n from the half-width you need: n ≈ (z·σ/h)².

Explain it another way

Intuitive

Throwing a hoop at a hidden peg: the method lands the hoop over the peg 95 times out of 100. After one throw you can't see whether this hoop caught it.

Technical

Normal-approximation (Wald) CI for a mean: x̄ ± z_{1−α/2}·s/√n. Exact for known σ and normal data; asymptotically correct otherwise. The t-interval replaces z with t_{n−1, 1−α/2}.

Mathematical

Coverage probability = P(μ ∈ [x̄ − z·s/√n, x̄ + z·s/√n]). With σ known it is exactly 1 − α. With s it is P(|T| ≤ z) where T ~ t_{n−1}, which is below 1 − α; for n = 3 and z = 1.96 it is about 81%.

Applied

Spacecraft navigation teams quote 'error ellipses' for a probe's predicted position: multi-dimensional confidence regions that decide whether a trajectory correction manoeuvre is needed.

Derivation: Building the interval from the sampling distribution
  1. For large n, the sample mean is approximately normal: x̄ ~ N(μ, σ²/n).

  2. Standardise: Z = (x̄ − μ)/(σ/√n) ~ N(0, 1). For a standard normal, P(−1.96 ≤ Z ≤ 1.96) = 0.95.

  3. Substitute: P(−1.96 ≤ (x̄ − μ)/(σ/√n) ≤ 1.96) = 0.95.

  4. Rearrange the inequality for μ: P(x̄ − 1.96·σ/√n ≤ μ ≤ x̄ + 1.96·σ/√n) = 0.95. The random quantity is x̄, so this is a statement about the interval, not about μ.

  5. σ is unknown, so replace it with s. For small n this extra uncertainty matters: use Student's t value (for example t = 2.26 instead of 1.96 when n = 10) or the interval will be too narrow.

  6. Result (normal approximation): x̄ ± z·s/√n, with z = 1.645 (90%), 1.96 (95%) or 2.576 (99%).

Worked example 1

n = 36 runs, x̄ = 52.4 ms, s = 4.8 ms. Give the 95% CI.

SE = 4.8/6 = 0.8 ms. h = 1.96 × 0.8 = 1.57 ms. CI: 52.4 ± 1.6 ms, i.e. 50.8 to 54.0 ms.

Worked example 2

How many runs would give a half-width of 0.5 ms with the same s?

n = (1.96 × 4.8/0.5)² = (18.8)² ≈ 354 runs. Precision is expensive.

Common mix-ups

Practice

Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.

W

Practice 2. Which statement correctly interprets a 95% confidence interval?

readings

Practice 4. With n = 4 runs, you build x̄ ± 1.96·s/√n. What is the main risk?

°C

Apply it

For your own 20 timings, build 90%, 95% and 99% intervals. Then build the 95% interval from the first 5 runs only, with z and with t (2.78 for n = 5). Which intervals overlap?

Reflect

Why does the simulator need many batches before the tally settles near 95%? What does that tell you about judging a method from one result?

Write your answer on paper or in your own notes. Lite never stores what you write.

Go further

Research mode: limits and open questions

Many fields now ask authors to report intervals instead of just p-values, because an interval shows the plausible size of an effect, not only whether it is distinguishable from zero.

← Is the difference real? Effect sizes and correlationPropagating uncertainty through a calculation →