Confidence Intervals and Test Assumptions › The Remarkable Equivalence

Michael BrenndoerferUpdated January 12, 20265 min read
Machine Learning from ScratchAll chapters
Part 2 of 9Hypothesis Testing
Chapter 13Confidence Intervals and Test Assumptions › The Remarkable Equivalence
Reading section 3 of 9 · The Remarkable Equivalence · 5 minSection 3 of 9 · 5 min

Book contents

Section 3 of 9 · 5 min read

Confidence Intervals and Test Assumptions › The Remarkable EquivalenceOne section · Sections in this chapter3 / 9 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Here's the key insight that connects confidence intervals to hypothesis testing: a 95% confidence interval contains exactly those parameter values that would NOT be rejected by a two-sided hypothesis test at the 0.05 significance level.

Why the Equivalence Holds

Let's prove this algebraically. Consider testing H0:μ=μ0H_0: \mu = \mu_0 versus H1:μ≠μ0H_1: \mu \neq \mu_0 at significance level α=0.05\alpha = 0.05.

We reject H0H_0 when the test statistic exceeds the critical value:

∣xˉ−μ0SE∣>t0.975,n−1\left| \frac{\bar{x} - \mu_0}{SE} \right| > t_{0.975, n-1}

Rearranging this inequality:

∣xˉ−μ0SE∣>t0.975  ⟺  ∣xˉ−μ0∣>t0.975⋅SE  ⟺  xˉ−μ0>t0.975⋅SEORxˉ−μ0<−t0.975⋅SE  ⟺  μ0<xˉ−t0.975⋅SEORμ0>xˉ+t0.975⋅SE\begin{aligned} \left| \frac{\bar{x} - \mu_0}{SE} \right| > t_{0.975} &\iff |\bar{x} - \mu_0| > t_{0.975} \cdot SE \\ &\iff \bar{x} - \mu_0 > t_{0.975} \cdot SE \quad \text{OR} \quad \bar{x} - \mu_0 < -t_{0.975} \cdot SE \\ &\iff \mu_0 < \bar{x} - t_{0.975} \cdot SE \quad \text{OR} \quad \mu_0 > \bar{x} + t_{0.975} \cdot SE \end{aligned}

The last line says: we reject H0H_0 when μ0\mu_0 falls outside the interval [xˉ−t0.975⋅SE,xˉ+t0.975⋅SE][\bar{x} - t_{0.975} \cdot SE, \bar{x} + t_{0.975} \cdot SE].

But this interval is exactly the 95% confidence interval! So:

  • μ0\mu_0 inside the CI ⇒\Rightarrow hypothesis test fails to reject H0H_0
  • μ0\mu_0 outside the CI ⇒\Rightarrow hypothesis test rejects H0H_0

The confidence interval is the set of all parameter values that would not be rejected as null hypotheses.

Visualizing the Equivalence

Out[4]:
Visualization
Number line showing confidence interval with examples of rejected and non-rejected hypothesis values.
The equivalence between confidence intervals and hypothesis tests. The 95% CI is shown as the blue bar. Any hypothesized value inside the interval (like mu0 = 255) would not be rejected. Any value outside (like mu0 = 240 or mu0 = 265) would be rejected. The CI simultaneously shows you the result of testing every possible null hypothesis.

Why This Matters Practically

This equivalence has important practical implications:

  1. Confidence intervals are more informative than p-values. A p-value tells you whether one specific null hypothesis is rejected. A confidence interval tells you which values would be rejected and which wouldn't. It's like the difference between asking "Is the speed limit 65 mph?" versus "What range of speed limits are consistent with my speedometer reading?"

  2. You can read significance from a CI. If a 95% CI for a difference doesn't include zero, the difference is significant at the 0.05 level. If the CI for a ratio doesn't include 1, the ratio is significant. You don't need to compute a separate test.

  3. CIs convey precision. A CI of [0.1, 0.3] and a CI of [-2, 5] might both exclude zero (both "significant"), but the first shows you know the effect is small and positive, while the second shows you barely know anything at all.

Out[5]:
Visualization
Two horizontal confidence intervals with different widths but the same center point.
Two studies with the same point estimate (effect = 2) but different precision. Study A has a narrow CI from 1.5 to 2.5. Study B has a wide CI from 0.2 to 3.8, suggesting high uncertainty about the true effect size. Both CIs exclude zero.