⚙️
  • Home
  • Foundations
  • Regression

Confidence intervals: an interactive coverage simulation

This simulation uses a population we completely know: a normal distribution with population mean \(\mu = 0\) and standard deviation \(\sigma = 1\). Each trial draws a new random sample, calculates its sample mean, and creates an approximate 95% confidence interval for \(\mu\).

Throughout this page, \(\mu\) denotes the fixed population mean (the quantity we want to learn), while \(\bar{X}\) denotes the sample mean (our estimate of it).

The dashed vertical line marks the true population mean. Blue intervals contain it; red intervals miss it. A 95% confidence level describes the long-run behavior of this procedure: across many independently constructed intervals, about 95% should contain \(\mu\). It does not guarantee that any particular interval will do so.

For each sample, the simulation constructs the approximate 95% confidence interval

\[ \bar{X} \pm 1.96 \frac{S}{\sqrt{n}}, \]

where \(\bar{X}\) is the sample mean, \(S\) is the sample standard deviation, and \(n\) is the sample size. The sample standard deviation is calculated from the same \(n\) observations:

\[ S = \sqrt{\frac{1}{n - 1}\sum_{i=1}^{n}\left(X_i - \bar{X}\right)^2}. \]

TipTry this

Begin with a few intervals, then add more. The occasional red interval makes the meaning of “95% confidence” visible. Reset and repeat: the exact number of misses changes each time, while the long-run pattern remains near 95% coverage.

No intervals yet. Add a small batch to begin.

Confidence intervals for the population mean contains μ misses μ

← Return to Foundations

MECE 4520 · Data Science for Mechanical Systems

 

Fall 2026