Statistics & Probability
Advanced

Pearson Correlation

Measures linear correlation between two variables.

Formula

r=∑(xi−xˉ)(yi−yˉ)∑(xi−xˉ)2∑(yi−yˉ)2r = \frac{\sum (x_i-\bar{x})(y_i-\bar{y})}{\sqrt{\sum(x_i-\bar{x})^2\sum(y_i-\bar{y})^2}}

Variables

x_i, y_iPaired data
\bar{x},\bar{y}Means

Example

r = +1 is a perfect straight-line rise, r = 0 means no linear relationship.

How it works

Pearson correlation quantifies how tightly two variables move together in a straight-line pattern, using a standardized version of covariance. The numerator adds up paired deviations from each mean, so values are positive when both variables are above or below their means together and negative when one is above while the other is below. The denominator rescales by the variables’ overall spread, which makes the result unitless and forces the value to stay between -1 and 1.

When to use it

Use this when you want to measure linear association between two quantitative variables, such as height vs. weight, study time vs. exam score, or temperature vs. electricity demand. It is especially useful when you need a comparable, scale-free measure of strength and direction.

Worked example, step by step

Data: (x, y) = (1,2), (2,3), (3,5), (4,4) Step 1: Find the means: x̄ = (1+2+3+4)/4 = 2.5, ȳ = (2+3+5+4)/4 = 3.5 Step 2: Compute deviations and products: (1-2.5)(2-3.5) = (-1.5)(-1.5) = 2.25 (2-2.5)(3-3.5) = (-0.5)(-0.5) = 0.25 (3-2.5)(5-3.5) = (0.5)(1.5) = 0.75 (4-2.5)(4-3.5) = (1.5)(0.5) = 0.75 Step 3: Sum the products: Σ(xi-x̄)(yi-ȳ) = 2.25+0.25+0.75+0.75 = 4.00 Step 4: Sum squared deviations for x: Σ(xi-x̄)^2 = 2.25+0.25+0.25+2.25 = 5.00 Step 5: Sum squared deviations for y: Σ(yi-ȳ)^2 = 2.25+0.25+2.25+0.25 = 5.00 Step 6: Substitute into the formula: r = 4.00 / sqrt(5.00×5.00) = 4.00 / 5.00 = 0.80 Final answer: r = 0.80, which indicates a fairly strong positive linear relationship.

Common mistakes to avoid

  • Interpreting r as causation instead of just association
  • Using Pearson correlation for clearly curved or non-linear patterns
  • Forgetting that outliers can strongly distort the result

Did You Know?

Correlation does not imply causation — ice-cream sales and drownings rise together, but neither causes the other.

Share this formula

Reviewed & maintained by the FormulaWon editorial teamLast reviewed September 2026