Section 1 Pearson r — measuring linear correlation
You have two lists of numbers — call them X and Y.
The question: when X is large, does Y tend to be large too?
Pearson r gives you a single number between −1 and +1 that answers exactly that —
assuming the relationship between them is a straight line.
01
Mean-center both variables
Subtract each variable's mean from its values. Now: positive = above average, negative = below average. Units don't matter anymore.
→
02
Multiply each pair of deviations
For each data point i, compute (xᵢ−x̄)·(yᵢ−ȳ). Both above average → positive product. One above, one below → negative product.
→
03
Sum and normalize
Sum all those products. Divide by the product of the two standard deviations. This rescales everything to [−1, +1] no matter what the original units were.
→
04
Read the result
r = +1: perfect line up ↗
r = −1: perfect line down ↘
r = 0: no linear trend
Weakness: outliers and curves break it.
r = −1: perfect line down ↘
r = 0: no linear trend
Weakness: outliers and curves break it.
r
=
Σ (xᵢ−x̄)(yᵢ−ȳ)
/
√[ Σ(xᵢ−x̄)² · Σ(yᵢ−ȳ)² ]
numerator: how much X and Y deviate together | denominator: normalises to [−1, +1]
The critical weakness of Pearson r:
It operates on raw values. One extreme outlier can yank the numerator massively, making r look huge even if the rest of the data shows no trend at all — or it can kill a real trend. It also completely misses relationships that are curved rather than straight.
It operates on raw values. One extreme outlier can yank the numerator massively, making r look huge even if the rest of the data shows no trend at all — or it can kill a real trend. It also completely misses relationships that are curved rather than straight.