Correlation Coefficient Calculator

Paste paired X and Y data to get Pearson’s r, r², the least-squares regression line and a significance test.

Pearson correlation (r)
0.976621

Very strong positive linear relationship; r² = 0.954 means about 95.4% of the variation in Y is explained by X.

Data with the least-squares lineY
Datay = 3.67857x + 48.0714
5055606570758012345678(1, 52)(2, 55)(3, 61)(4, 64)(5, 62)(6, 70)(7, 74)(8, 79)X
Coefficient of determination (r²)
0.953789
Regression line
y = 3.67857x + 48.0714
Slope (b)
3.678571
Intercept (a)
48.071429
p-value (H₀: ρ = 0)
0.000031
Number of pairs
8
Show the working
  1. n = 8, x̄ = 4.5, ȳ = 64.625
  2. Sxy = Σ(x − x̄)(y − ȳ) = 154.5
  3. Sxx = Σ(x − x̄)² = 42, Syy = Σ(y − ȳ)² = 595.875
  4. r = Sxy ÷ √(Sxx · Syy) = 154.5 ÷ √(42 × 595.875) = 0.976621
  5. Slope b = Sxy ÷ Sxx = 3.67857; intercept a = ȳ − b·x̄ = 48.0714
  6. t = r√(n − 2) ÷ √(1 − r²) with df = 6 → two-tailed p = 0.00003139

Runs entirely in your browser. Nothing you enter is uploaded.

Formula

r = Σ(x − x̄)(y − ȳ) ÷ √(Σ(x − x̄)² · Σ(y − ȳ)²)b = Sxy ÷ Sxx, a = ȳ − b·x̄ → ŷ = a + bxt = r√(n − 2) ÷ √(1 − r²), df = n − 2

How it works

Pearson’s correlation coefficient r measures how closely two variables follow a straight-line relationship. It ranges from −1 (a perfect downward line) through 0 (no linear relationship) to +1 (a perfect upward line). Roughly, |r| above 0.7 is considered strong and below 0.3 weak, though what counts as meaningful varies by field.

Squaring r gives the coefficient of determination r², the share of the variation in Y that the straight line accounts for. An r of 0.8 means r² = 0.64, so 64% of the variation is explained and 36% is left over.

The regression (least-squares) line is the straight line that makes the sum of squared vertical distances from the points as small as possible. Use it to predict Y from X within the range of your data; extrapolating far beyond it is risky.

Frequently asked questions

Does a strong correlation prove causation?

No. Two variables can move together because a third factor drives both, or by coincidence. Ice-cream sales and drowning deaths are correlated because both rise in hot weather.

Can r be near 0 even if the variables are related?

Yes. Pearson’s r only detects straight-line patterns. A U-shaped relationship can have r ≈ 0. Always look at a scatter plot.

What does the p-value tell me?

It tests whether the true population correlation could be zero. A small p-value (say below 0.05) suggests the correlation in your sample is unlikely to be due to chance alone.

esc