# Why we square: variance, sums of squares and n − 1

> Why spread formulas square deviations, variance s² and σ², sums of squares split into between and within, λ as a sum of squared loadings, and the idea behind n − 1 and degrees of freedom.

- Course: [Math for Statistics and Unit Economics](https://productovi.com/courses/math-basics.md)
- Module: Squares, roots and distances
- Lesson 13/36, ~28 min
- Source: https://productovi.com/courses/math-basics/why-we-square

## Deviations that don't cancel

**Alex Tutor:** Module 4 is about squares, roots and distances. Remember the five Klasna learners with 6, 9, 4, 7 and 14 lessons? Their deviations from the mean of 8 added up to zero, so they can't measure spread directly.

**Sofia:** So we square them. But why squares and not just drop the minus signs?

**Alex Tutor:** Dropping the signs works too: the mean absolute deviation is (2 + 1 + 4 + 1 + 6) ÷ 5 = 2.8. Squares win for two reasons: big deviations count more, and squared pieces add up neatly, which the rest of statistics relies on.

**Alex Tutor:** The squares are 4, 1, 16, 1 and 36. Their sum, the **sum of squares**, is 58, and the learner with 14 lessons alone gives 36 of it. A deviation twice as big counts four times as much.

![A cat lays square rugs of different sizes in a row: four small ones and one very large orange rug that is bigger than all the others together.](https://productovi.com/courses/math-basics/inline/m4-l1-i1.webp)

*Squaring lets the far values dominate.*

![The deviations −2, +1, −4, −1 and +6 drawn as squares with areas 4, 1, 16, 1 and 36; together 58, and the single +6 makes up 36 of it.](https://productovi.com/courses/math-basics/diagrams/m4-l1-squares.png)

*The sum of squares is a sum of areas.*

> **Exercise:** Why do spread formulas square the deviations? Select all that apply.

**Alex Tutor:** One quick check on those tiles before we divide anything.

> **Exercise:** In a sum of squares, a deviation twice as big as another adds twice as much.

## Variance and n − 1

**Alex Tutor:** The **variance** is the sum of squares divided by n − 1: s² = 58 ÷ 4 = **14.5**. Its units are squared, "lessons squared", which is why the next lesson takes a square root.

$$
s^2 = \frac{\sum (x_i - \bar{x})^2}{n - 1} \qquad \sigma^2 = \frac{\sum (x_i - \mu)^2}{N}
$$

*s²: variance of a sample, divided by n − 1. σ²: variance of a whole population, around the true mean μ, divided by N.*

**Sofia:** And when would I divide by N?

**Alex Tutor:** Only when you truly have everyone: all 1,120 active learners in March, not five of them. In product work that's rare. Spreadsheets have both versions: VAR.S divides by n − 1, VAR.P by N.

**Alex Tutor:** Try it on a real Klasna case.

> **Exercise:** Klasna has the number of lessons each of its 1,120 learners active in March took that month, every one of them, and wants the spread of exactly this group. Which variance fits?

**Sofia:** OK. But why n − 1 and not 5 for the sample?

**Alex Tutor:** Because the deviations must add to zero. Once you know four of them, −2, +1, −4 and −1, the fifth has to be +6. Only four pieces are free. That count is called the **degrees of freedom**.

**Alex Tutor:** Check the free-pieces idea on other numbers.

> **Exercise:** Five deviations from a sample mean add up to zero, as they always do. Four of them are −3, +5, −1 and +2. What is the fifth?

**Alex Tutor:** Another way to see it: x̄ comes from the same data, so the data sit a bit closer to x̄ than to the true μ. The sum of squares comes out slightly small, and dividing by n − 1 instead of n corrects for that.

> **Exercise:** A sample of four tutors gave 3, 5, 7 and 9 trial lessons. What is the sample variance s²? Give two decimals.

## Degrees of freedom by name

**Alex Tutor:** You'll meet degrees of freedom in many formulas. Each is "pieces of data minus the things estimated from them". One sample: n − 1. Two samples with two means: n₁ + n₂ − 2. k groups compared: k − 1. A table with r rows and c columns: (r − 1)(c − 1).

**Sofia:** So it's always a count, never something to compute from values.

> **Exercise:** A two-sample t-test compares 12 learners on one plan with 15 on another. How many degrees of freedom does the pooled test have, n₁ + n₂ − 2?

## Splitting a sum of squares

**Alex Tutor:** Squares split cleanly. Two tutors' ratings: A got 4 and 6 (mean 5), B got 8 and 10 (mean 9); the grand mean is 7. Total sum of squares around 7: 9 + 1 + 1 + 9 = **20**.

**Alex Tutor:** **Between** groups: each value replaced by its group mean, 2 × (5 − 7)² + 2 × (9 − 7)² = 16. **Within** groups: each value around its own group mean, 1 + 1 + 1 + 1 = 4. And 16 + 4 = 20 exactly.

![Ratings 4 and 6 (mean 5) and 8 and 10 (mean 9) around a grand mean of 7: total sum of squares 20 = between groups 16 + within groups 4.](https://productovi.com/courses/math-basics/diagrams/m4-l1-ss-split.png)

*Most of the spread here is between the two tutors.*

**Sofia:** That's what ANOVA compares, then: between against within.

**Alex Tutor:** Yes. And factor analysis uses squares too: a factor's strength λ = Σa², the sum of its squared loadings. Loadings 0.8, 0.7 and 0.6 give 0.64 + 0.49 + 0.36 = **1.49**.

> **Exercise:** Two groups of 3 learners have mean scores 4 and 8; the grand mean is 6. What is SS_between = Σ nⱼ(x̄ⱼ − x̄)²?

> **Exercise:** A factor has loadings 0.9, 0.6 and 0.5 on three survey questions. What is its λ = Σa²?

## Your turn: explain n − 1

**Alex Tutor:** A colleague asks why the spreadsheet's sample variance divides by n − 1 and thinks it's a typo. Explain it in plain words.

**Sofia:** I'll use the five deviations.

> **Exercise:** Explain to a colleague, in three or four sentences, why the sample variance divides by n − 1 instead of n. Use the deviations −2, +1, −4, −1, +6 from the mean 8 as your example.

## Where you will meet this

> **In short**
>
> - Deviations cancel, so spread formulas **square** them: squares are never negative and weigh big deviations more.
> - **Sum of squares** = Σ(xᵢ − x̄)². **Variance** s² = sum of squares ÷ (n − 1) for a sample; σ² divides by N around μ. Units are squared.
> - **Degrees of freedom** = data points minus what was estimated from them: n − 1, n₁ + n₂ − 2, k − 1, (r − 1)(c − 1).
> - Sums of squares split: **total = between + within**. A factor's strength **λ = Σa²**.

> **These lessons use it**
>
> - [Measures of spread](/courses/statistics-for-pm-and-marketers/spread): s² with n − 1 and σ² with N.
> - [Two-sample t-test](/courses/statistics-for-pm-and-marketers/t-test): n₁ + n₂ − 2 degrees of freedom.
> - [One-way ANOVA](/courses/statistics-for-pm-and-marketers/anova): SS_between against SS_within.
> - [Repeated measures ANOVA](/courses/statistics-for-pm-and-marketers/repeated-measures): a total sum of squares split into three parts.
> - [Factor analysis](/courses/statistics-for-pm-and-marketers/factor-analysis): λ as a sum of squared loadings.

**Alex Tutor:** Next time: the square root and √n, which bring the units back and explain why more data narrows an estimate.

- Previous lesson: [What do we divide by? Denominator traps](https://productovi.com/courses/math-basics/choosing-the-denominator.md)
- Next lesson: [Square roots and √n: SD and the standard error](https://productovi.com/courses/math-basics/square-roots-and-root-n.md)

---
Productovi Learning. Free, no sign-up needed to read.
