ANOVA (Analysis of Variance) › The Logic of ANOVA: Comparing Variances to Test Means

Michael BrenndoerferJanuary 5, 20264 min read
Machine Learning from ScratchAll chapters
Part 2 of 9Hypothesis Testing
Chapter 17ANOVA (Analysis of Variance) › The Logic of ANOVA: Comparing Variances to Test Means
Reading section 3 of 13 · The Logic of ANOVA: Comparing Variances to Test Means · 4 minSection 3 of 13 · 4 min

Book contents

Section 3 of 13 · 4 min read

ANOVA (Analysis of Variance) › The Logic of ANOVA: Comparing Variances to Test MeansOne section · Sections in this chapter3 / 13 ↓
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

ANOVA's name, "Analysis of Variance," seems paradoxical. If we want to compare means, why analyze variances? The genius of ANOVA lies in recognizing that differences among means manifest as a specific pattern of variance.

The Core Insight

Consider three groups with potentially different population means μ1\mu_1, μ2\mu_2, and μ3\mu_3. When we collect samples from these groups, we observe two types of variation:

1. Within-group variation: How much individuals vary around their own group mean. This reflects natural variability in the data, measurement error, and individual differences. This variation exists regardless of whether the population means differ.

2. Between-group variation: How much the group means vary around the overall (grand) mean. This reflects sampling variation plus any true differences among population means.

If all population means are equal, the between-group variation should be similar to what we'd expect from sampling variation alone. The group means will differ somewhat, but only because of random sampling, not because the populations are truly different.

But if population means differ, the between-group variation will be inflated beyond what sampling alone would produce. The group means will be more spread out than chance would predict.

ANOVA formalizes this by computing the ratio:

F=Between-group variance estimateWithin-group variance estimateF = \frac{\text{Between-group variance estimate}}{\text{Within-group variance estimate}}
  • If F≈1F \approx 1: Between and within variation are similar; no evidence of mean differences
  • If F≫1F \gg 1: Between variation is much larger than within; evidence that means differ
Out[3]:
Visualization
Scatter plot showing three groups with similar means and small between-group variation.
Groups with similar means. The between-group variation (spread of group means around the grand mean) is comparable to within-group variation, yielding F near 1.
Scatter plot showing three groups with different means and large between-group variation.
Groups with different means. The between-group variation is much larger than within-group variation, yielding a large F.