Correlation Coefficient Calculator
What this means
How this correlation calculator works
It works out the Pearson correlation coefficient, written r. This number shows how closely two sets of numbers move together in a straight line.
How to read r
- +1: a perfect positive straight-line link. When X goes up, Y always goes up.
- 0: no straight-line link.
- −1: a perfect negative link. When X goes up, Y always goes down.
As a rough guide, values above 0.7 (or below −0.7) are often called strong, and values between −0.3 and 0.3 weak. What counts as strong depends on your field.
The formula
r = Σ(x − x̄)(y − ȳ) ÷ √[Σ(x − x̄)² × Σ(y − ȳ)²]
Here x̄ and ȳ are the averages of X and Y.
Worked example
X = 1, 2, 3, 4, 5 and Y = 2, 4, 5, 4, 5. The averages are x̄ = 3 and ȳ = 4.
- Σ(x − x̄)(y − ȳ) = 6
- Σ(x − x̄)² = 10 and Σ(y − ȳ)² = 6
- r = 6 ÷ √(10 × 6) = 6 ÷ 7.75 ≈ 0.77, a fairly strong positive link
Things to watch
- Correlation is not causation. Two things can move together because a third thing drives both.
- Outliers can push r up or down a lot. Always look at the scatter plot.
- Pearson only measures straight-line links. A curved pattern can have r near 0 even when the link is strong.
Frequently asked questions
How many data points do I need?
More is better. With fewer than about 10 pairs, a high r can easily happen by chance, so check the p-value as well.
What is the difference between Pearson and Spearman correlation?
Pearson measures straight-line links using the actual values. Spearman uses the ranks of the values, so it also catches curved links that always go the same way, and it is less affected by outliers.