← SciSim / Statistics
Confidence Intervals
📊 Tier: Standard Undergraduate
§1 Interactive Simulation
True μ
0.00
σ (known)
1.00
n
30
Confidence level
95%
CI width
Coverage
True μ 0
σ (population) 1
n (sample size) 30
Confidence level % 95
§2 The Idea, Step by Step

Start: a range, not a single guess

Suppose you want the average height of every student in a huge school. You can't measure all of them, so you measure 30 and take the average. Your average won't land exactly on the truth — measure a different 30 and you'd get a slightly different number. So instead of one guess, you give a range that you're fairly sure the real average falls inside: "probably between 160 and 168 cm." That range is a confidence interval.

Build: where the width comes from

Three things set the interval. The sample mean $\bar{x}$ is its center. The population spread $\sigma$ and the sample size $n$ set how far it reaches, through the standard error $\sigma/\sqrt{n}$ — the typical wobble of a sample mean. A handy rule for 95% confidence is to reach about two standard errors each way:

$$\bar{x} \;\pm\; 2\,\frac{\sigma}{\sqrt{n}}$$

Say $\bar{x}=164$ cm, $\sigma=10$, and $n=25$. Then $\sigma/\sqrt{n}=10/5=2$, so the interval is $164\pm 2(2)=164\pm4=[160,168]$ cm. Bigger $n$ shrinks the wobble and tightens the range; more spread $\sigma$ widens it.

Deepen: what "95%" really means

The precise interval replaces the "2" with the exact normal critical value $z_{\alpha/2}$ (1.960 for 95%, 2.576 for 99%):

$$\bar{x} \;\pm\; z_{\alpha/2}\,\frac{\sigma}{\sqrt{n}}$$

Here is the subtle part. The true mean $\mu$ is a fixed number — it isn't random. What is random is the interval, because it's built from a random sample. "95% confidence" describes the procedure: if you repeated the whole study many times, about 95% of the intervals you'd build would contain $\mu$. It does not say there's a 95% chance $\mu$ sits in your one particular interval — that one already either does or doesn't. In the sim, the True μ slider sets the (normally hidden) target, $\sigma$ and $n$ control the width through $\sigma/\sqrt{n}$, and Confidence level sets $z_{\alpha/2}$.

Try this in the sim above

Click Run 100 CIs at 95% and count the red bars — roughly 5 of every 100 miss $\mu$, just as advertised. Drop the confidence level to 90% and run again: the bars get narrower but more turn red. Then slide $n$ from 30 up to 200 on the "Width vs n" tab and watch the width fall like $1/\sqrt{n}$ — quadrupling $n$ only halves the width.

§3 Mathematical Derivation

z-Interval for μ (known σ) — Neyman 1937

$$\boxed{\bar{X} \pm z_{\alpha/2}\frac{\sigma}{\sqrt{n}}}$$

where $z_{\alpha/2}=\Phi^{-1}(1-\alpha/2)$. For 95% CI: $z_{0.025}=1.960$.

Derivation

STEP 1 — Pivot

Since $\bar{X}\sim\mathcal{N}(\mu,\sigma^2/n)$, we have $Z=(\bar{X}-\mu)/(\sigma/\sqrt{n})\sim\mathcal{N}(0,1)$. This pivotal quantity has distribution not depending on the unknown $\mu$.

STEP 2 — Probability Statement

$$P\!\left(-z_{\alpha/2}\le \frac{\bar{X}-\mu}{\sigma/\sqrt{n}}\le z_{\alpha/2}\right)=1-\alpha$$

STEP 3 — Invert to Get CI

Rearranging for $\mu$: $$P\!\left(\bar{X}-z_{\alpha/2}\frac{\sigma}{\sqrt{n}}\le\mu\le\bar{X}+z_{\alpha/2}\frac{\sigma}{\sqrt{n}}\right)=1-\alpha$$

STEP 4 — Key Interpretation

The random quantity is the INTERVAL $[\bar{X}\pm z_{\alpha/2}\sigma/\sqrt{n}]$, not $\mu$. The probability $(1-\alpha)$ refers to the long-run proportion of intervals (from repeated sampling) that contain $\mu$, which is fixed. Saying "95% chance μ is in this interval" is WRONG — μ is not random.

STEP 5 — Width Analysis

$$\text{Width} = 2z_{\alpha/2}\frac{\sigma}{\sqrt{n}}$$

Width decreases as $1/\sqrt{n}$ — to halve the width, quadruple $n$. Width also decreases with lower confidence level (smaller $z_{\alpha/2}$). There is always a tradeoff: narrower CI = lower confidence.

Worked Example

Problem: Mean exam score from n=64 students: $\bar{x}=72.4$, known $\sigma=8$. Compute 99% CI.

$z_{0.005}=\Phi^{-1}(0.995)=2.576$

$$\text{CI} = 72.4\pm 2.576\cdot\frac{8}{\sqrt{64}} = 72.4\pm 2.576 = [69.82,\; 74.98]$$

We are 99% confident the true mean exam score lies between 69.82 and 74.98. (The procedure that generated this interval covers μ 99% of the time.)

Casella & Berger — Statistical Inference, Ch. 9: "Interval Estimation"
DeGroot & Schervish — Probability and Statistics, Ch. 8.5
§4 FAQ
Seeing Theory — seeing-theory.brown.edu
§5 Misconceptions & Common Errors
❌ Misconception 1 — Most common CI error

"A 95% CI means there is a 95% probability that μ is inside this specific interval."
μ is a fixed (unknown) constant. After the interval is computed, μ either is or isn't inside it — probability 0 or 1. The 95% refers to the procedure: if you repeat the study 100 times, approximately 95 of the resulting intervals will contain μ. This is a statement about the method, not about any single interval. The coverage demo visually proves this.
📖 Casella & Berger — Ch. 9.2

❌ Misconception 2

"A wider CI means the experiment was conducted poorly."
CI width reflects natural uncertainty given the study design. A wide CI simply means the data doesn't rule out many values of μ — this could reflect small n, large σ, or low confidence level. A narrow CI requires larger n. Reporting a CI is always more informative than a p-value alone — it shows both the estimate and precision.
📖 DeGroot & Schervish — Ch. 8.5

❌ Misconception 3

"Non-overlapping 95% CIs always means the groups are significantly different."
Two 95% CIs that don't overlap imply the two-sample test is significant at roughly α=0.005, not α=0.05. Overlapping CIs do NOT necessarily mean non-significance. The correct test for comparing two means requires computing the actual test statistic for the difference, not visually comparing CIs.
📖 Schenker & Gentleman (2001), American Statistician

❌ Error 1

Using z instead of t when σ is unknown
✅ When σ is unknown (almost always), use $\bar{x}\pm t_{n-1,\alpha/2}\cdot s/\sqrt{n}$ with Student's t distribution. The z-interval requires known σ.
🔍 Students use z=1.96 regardless of whether σ is known.

❌ Error 2

Forgetting to check normality assumption for small n
✅ For n<30 and non-normal populations, the z/t CI may not have correct coverage. Use bootstrap CIs or exact methods when normality is doubtful.
🔍 Students apply the z-interval formula mechanically without checking CLT applicability.

❌ Error 3

Using $\sigma/n$ instead of $\sigma/\sqrt{n}$ for the margin of error
✅ Standard error = $\sigma/\sqrt{n}$, not $\sigma/n$. Using $\sigma/n$ gives a margin of error that shrinks too fast — e.g., with n=100 you'd use $\sigma/100$ instead of $\sigma/10$, underestimating uncertainty by a factor of 10.
🔍 Confusing $n$ and $\sqrt{n}$ in the denominator.

Casella & Berger — Statistical Inference, Ch. 9
DeGroot & Schervish — Probability and Statistics, Ch. 8