Correlation Calculator

Calculate the Pearson correlation coefficient (r) between two data sets

Frequently Asked Questions

The Pearson correlation coefficient is the covariance of the two variables divided by the product of their standard deviations: r = Σ[(x−x̄)(y−ȳ)] ÷ √[Σ(x−x̄)² × Σ(y−ȳ)²]. It always falls between −1 and +1.
r = +1 is a perfect positive relationship (as one variable rises, so does the other, exactly proportionally). r = −1 is a perfect negative relationship (as one rises, the other falls proportionally). r = 0 means no linear relationship. Values near ±0.7 to ±1.0 are usually considered strong, ±0.3 to ±0.7 moderate, and below ±0.3 weak.
No — correlation only measures whether two variables move together, not why. Two variables can be strongly correlated because one causes the other, because both are caused by a third factor, or purely by coincidence. "Correlation does not imply causation" is one of the most important rules in statistics.
R² is simply the correlation coefficient squared. It represents the proportion of variance in one variable that's statistically explained by the other — an r of 0.8 gives an R² of 0.64, meaning 64% of the variation is explained by the linear relationship.
It's the best-fit straight line through your data (y = mx + b), found using the same least-squares method as the correlation itself. You can use it to estimate a y value for any new x value, though the estimate is only as reliable as how strong your correlation is.

Pearson correlation formula

r = Σ (x − x̄)(y − ȳ) ÷ √[Σ (x − x̄)² × Σ (y − ȳ)²]

r measures the strength and direction of a linear relationship, from −1 (perfect negative) through 0 (no linear relationship) to +1 (perfect positive). The calculator also gives the least-squares line y = slope × x + intercept, where slope = Σ (x − x̄)(y − ȳ) ÷ Σ (x − x̄)².

Example

X = 1, 2, 3, 4, 5 and Y = 2, 4, 5, 4, 5. The means are 3 and 4, the sum of cross-products is 6, and the sums of squares are 10 for X and 6 for Y. r = 6 ÷ √60 = 0.775, a strong positive correlation. r² = 0.60, so the line y = 0.6x + 2.2 explains 60% of the variation in Y.

Interpreting r

|r|Strength
0.7 to 1.0Strong
0.3 to 0.7Moderate
0 to 0.3Weak

These cutoffs are conventions; in some fields an r of 0.3 is considered meaningful, in physics 0.9 might be disappointing.

Is the correlation significant?

With few data points, a large r can still be chance. Test it with t = r × √(n − 2) ÷ √(1 − r²), with n − 2 degrees of freedom. In the example, t = 0.775 × √3 ÷ √0.4 = 2.12 with 3 degrees of freedom, a two-tailed p-value of about 0.12, so five points are not enough to rule out chance at the 5% level. With 30 data points, an r of 0.36 or more would be significant.

Common pitfalls

  • Correlation is not causation. Ice cream sales and drownings are correlated because both rise in summer.
  • Outliers can create or hide a correlation; always look at a scatter plot.
  • Non-linear relationships: a perfect U-shape can have r near 0. Spearman's rank correlation handles monotonic curves and ranked data.
  • Restricted range: looking only at high-scoring students hides the correlation that exists across all students.

For averages, use the average calculator; for planning how much data you need, the sample size calculator; and to compare two rates, the A/B test significance calculator.