# Pythagoras in statistics: distances and errors in quadrature

> Euclidean and Manhattan distance, why independent errors add as squares, the pooled SE of a z-test vs the unpooled SE of an interval, and how to read the Wilson and Newcombe interval formulas.

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

## The shortcut across

**Alex Tutor:** Still on Klasna's product team, with a rule from school, Pythagoras: in a right triangle, c² = a² + b². With legs 3 and 4, the diagonal is √(9 + 16) = 5. Statistics uses this rule far more often than it admits.

![Seen from above, a cat heads diagonally across a rectangular rug toward an orange bowl in the far corner; a dotted line along the edges marks the longer way round.](https://productovi.com/courses/math-basics/inline/m4-l3-i1.webp)

*The diagonal is shorter than the two sides added together.*

**Sofia:** Where? I don't see triangles in a test report.

**Alex Tutor:** First, in distances. Describe each learner by two numbers: lessons a month and minutes of homework a week. A has (6, 30), B has (9, 34). They differ by 3 and 4, so the **Euclidean distance** is √(3² + 4²) = **5**.

$$
d_{\text{Euclid}} = \sqrt{\sum_i (x_i - y_i)^2} \qquad d_{\text{Manhattan}} = \sum_i |x_i - y_i|
$$

*Euclidean: the straight line, any number of features. Manhattan: along the grid; |x| is the absolute value, the number without its sign.*

**Alex Tutor:** The **Manhattan distance** walks along the grid instead: |3| + |4| = 7. Clustering uses distances like these to group similar learners.

![Learner A at (6, 30) and learner B at (9, 34): the Euclidean distance is the diagonal, √(3² + 4²) = 5; the Manhattan distance follows the grid, 3 + 4 = 7.](https://productovi.com/courses/math-basics/diagrams/m4-l3-distance.png)

*Straight line or grid: two ways to measure how far apart two learners are.*

> **Exercise:** Two learners are described by (lessons a month, homework minutes a week): (2, 7) and (8, 15). What is the Euclidean distance between them?

**Alex Tutor:** The grid version, in numbers.

> **Exercise:** Two learners are described by (lessons a month, homework minutes a week): (3, 10) and (7, 4). What is the Manhattan distance Σ|xᵢ − yᵢ| between them?

## Errors add as squares

**Alex Tutor:** Second, in errors. Variant A converts at 10% with SE 0.6 pp; variant B at 12% with SE 0.8 pp. The SE of the **difference** is not 0.6 + 0.8. Independent errors add as squares: √(0.6² + 0.8²) = √1.00 = **1.0 pp**.

**Sofia:** Why not 1.4?

**Alex Tutor:** Because the two errors are random and independent: when A is measured too high, B is as likely too low as too high, so they partly cancel. Adding 1.4 assumes they always push the same way. Variances add; SEs add like the sides of a triangle.

![A right triangle with legs SE_A = 0.6 pp and SE_B = 0.8 pp has a hypotenuse of 1.0 pp, the SE of the difference; adding the legs would give 1.4 pp.](https://productovi.com/courses/math-basics/diagrams/m4-l3-quadrature.png)

*Independent errors combine like the sides of a right triangle.*

**Alex Tutor:** Projects use the same rule: if two tasks run one after another with uncertainty σ = 3 and 4 days, the total uncertainty is √(9 + 16) = 5 days, not 7. In general σ_total = √Σσ².

> **Exercise:** Variant A's conversion has SE 0.9 pp and variant B's has SE 1.2 pp, measured independently. What is the SE of the difference B − A, in pp?

> **Exercise:** Three tasks run one after another with independent uncertainties σ = 2, 3 and 6 days. What is σ_total = √Σσ², in days?

**Alex Tutor:** One condition hides behind all of this. True or false?

> **Exercise:** If the errors of two estimates always push the same way (both too high or both too low together), their combined uncertainty is closer to the plain sum σ₁ + σ₂ than to √(σ₁² + σ₂²).

## Pooled or unpooled

**Alex Tutor:** In a conversion test you'll see two versions of this SE. The **z-test** asks "what if there's no difference?", so it uses one pooled rate p̄ for both groups. The **interval for the difference** uses each group's own rate.

$$
SE_{\text{test}} = \sqrt{\bar{p}(1-\bar{p})\left(\tfrac{1}{n_1} + \tfrac{1}{n_2}\right)} \qquad SE_{\text{interval}} = \sqrt{\tfrac{p_1(1-p_1)}{n_1} + \tfrac{p_2(1-p_2)}{n_2}}
$$

*Both are Pythagoras: a square root of a sum of two variances. The test assumes the rates are equal; the interval doesn't.*

**Sofia:** Do they give different numbers?

**Alex Tutor:** Close ones when the rates are close. With 2,000 users each at 10% and 12%, both come out at about 0.99 pp. They drift apart when the two rates are far apart.

> **Exercise:** You run a z-test of "no difference between A and B" for two conversion rates. Which standard error does it use?

## Reading Wilson and Newcombe

**Alex Tutor:** Product analytics reports intervals by **Wilson** and **Newcombe**. You don't need to derive them, only to recognize the parts. Wilson for one share has a center nudged toward 50% and a square root of p(1 − p)/n with a small correction.

$$
\frac{\overbrace{p + \frac{z^2}{2n}}^{\text{center, nudged}} \pm z\overbrace{\sqrt{\frac{p(1-p)}{n} + \frac{z^2}{4n^2}}}^{\text{SE with a correction}}}{1 + \frac{z^2}{n}}
$$

*For p = 5%, n = 400, z = 1.96: about 3.3% to 7.6%, centered near 5.4% rather than 5%.*

**Alex Tutor:** First, read the centre of that formula.

> **Exercise:** A Wilson interval for a 5% conversion on 400 users runs from about 3.3% to 7.6%, centred near 5.4%. Why is the centre above 5%?

**Alex Tutor:** **Newcombe** builds the interval for a difference from the two Wilson intervals, and combines their one-sided widths with Pythagoras: √(width_A² + width_B²). Same idea as before, just with Wilson's widths.

**Sofia:** So whenever I see a square root of a sum of squares, I should think "independent pieces combined".

**Alex Tutor:** That's the whole lesson in one sentence. Distances between learners, errors of two groups, risks of two tasks: the same shape every time.

> **Exercise:** How does Newcombe's interval combine the two groups' one-sided widths w_A and w_B?

## Your turn: the colleague's 1.4

**Alex Tutor:** A colleague reads the test: A at 10% (SE 0.6 pp), B at 12% (SE 0.8 pp). "SE of the difference is 1.4, so the 2 pp gap is only 1.4 SEs: noise." Reply.

**Sofia:** I'll redo the square root before anything else.

> **Exercise:** A colleague says: "A is 10% (SE 0.6 pp), B is 12% (SE 0.8 pp). The SE of the difference is 0.6 + 0.8 = 1.4, so the 2 pp gap is only about 1.4 SEs." Correct the SE of the difference, recompute how many SEs the gap is, and explain in one sentence why SEs don't simply add.

## Where you will meet this

> **In short**
>
> - **Euclidean distance** = √Σ(xᵢ − yᵢ)²; **Manhattan** = Σ|xᵢ − yᵢ|.
> - Independent errors add **in quadrature**: SE_diff = √(SE₁² + SE₂²), σ_total = √Σσ². Never add SEs directly.
> - The **z-test** uses a pooled SE from p̄ (it assumes no difference); the **interval of a difference** uses the unpooled SE.
> - **Wilson**: a center nudged toward 50% ± z × a corrected SE. **Newcombe**: two Wilson widths combined by Pythagoras.

> **These lessons use it**
>
> - [Two-sample t-test](/courses/statistics-for-pm-and-marketers/t-test): the SE of a difference of two means.
> - [Conversion rates and the two-proportion z-test](/courses/statistics-for-pm-and-marketers/conversion-rate-tests): the pooled SE of the test.
> - [Clustering for customer segmentation](/courses/statistics-for-pm-and-marketers/clustering): Euclidean distance between customers.
> - [Case: reading a finished test](/courses/product-analytics/reading-a-test): Wilson and Newcombe intervals.

**Alex Tutor:** Next time: standardizing, which puts different scales side by side so distances and comparisons make sense.

- Previous lesson: [Square roots and √n: SD and the standard error](https://productovi.com/courses/math-basics/square-roots-and-root-n.md)
- Next lesson: [Standardizing: z, CV, effect size and r](https://productovi.com/courses/math-basics/standardizing.md)

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