How to Calculate the Correlation Coefficient (Pearson r)
Given n paired observations (x₁, y₁), (x₂, y₂), …, (xₙ, yₙ), Pearson's product-moment correlation coefficient standardizes how X and Y co-vary around their respective sample means x̄ and ȳ:
r = Σ(xᵢ − x̄)(yᵢ − ȳ) ÷ √[ Σ(xᵢ − x̄)² · Σ(yᵢ − ȳ)² ] = SS_xy ÷ √(SS_xx · SS_yy)
- Find both sample means: Compute
x̄ = (Σx) ÷ n and ȳ = (Σy) ÷ n. If you also need medians, modes, or outlier fences on a single column first, check our mean median mode calculator. - Compute deviations and cross-products: For every pair, subtract the mean to get
(xᵢ − x̄) and (yᵢ − ȳ). When above-average X values pair with above-average Y values, their product is positive; when above-average X pairs with below-average Y, their product is negative. - Divide by geometric spread: Dividing
SS_xy by √(SS_xx · SS_yy) cancels out physical measurement units—so converting temperatures from Celsius to Fahrenheit or distances from miles to kilometers leaves r completely unchanged!
How to Interpret r: Strength, Sign, and R²
Positive, negative, and zero correlation
A positive correlation (0 < r ≤ +1) means X and Y move in the same direction: higher study hours tend to pair with higher test scores. A negative correlation (−1 ≤ r < 0) means X and Y move in opposite directions: higher unit prices tend to pair with fewer units sold. Note that r = −0.85 is a stronger linear relationship than r = +0.60 because |−0.85| > |+0.60|!
Correlation strength guidelines
| |r| Range | R² (Variance Explained) | Practical Interpretation |
|---|
| 0.90 to 1.00 | 81% to 100% | Very strong linear alignment (common in physics/calibration). |
| 0.70 to 0.89 | 49% to 79% | Strong linear relationship; reliable trendline predictions. |
| 0.40 to 0.69 | 16% to 48% | Moderate relationship (typical in behavioral & business data). |
| 0.10 to 0.39 | 1% to 15% | Weak linear trend; wide scatter around the regression line. |
| 0.00 to 0.09 | < 1% | Negligible or zero linear association. |
Pearson r vs Spearman rank correlation (ρ)
This calculator outputs both Pearson r and Spearman's rank correlation (ρ) side by side so you can spot curvature or outlier distortion immediately. Click the Curved growth preset above to see why: exponential pairs (1, 2) through (8, 460) bend upward sharply, pulling linear Pearson r down to roughly 0.78 even though Y increases every single time X increases — which Spearman captures as ρ = 1.000!
Testing Statistical Significance: t-Statistic and p-Value
Sample size matters enormously when judging correlation. With only n = 4 pairs, even random coins can produce r = 0.75 fairly often; with n = 200 pairs, r = 0.20 is highly unlikely to happen by pure luck. To test the null hypothesis H₀: ρ = 0 (no linear correlation in the underlying population), the calculator computes Student's t-statistic with df = n − 2 degrees of freedom:
t = (r · √(n − 2)) ÷ √(1 − r²)
When the resulting two-tailed p-value is smaller than 0.05, the correlation is statistically significant at the 95% confidence level.
Correlation Does Not Imply Causation (and Why You Should Plot Your Data)
Even when r = 0.92 and p < 0.0001, correlation alone cannot prove that changing X causes Y to change — a lurking confounding variable (like summer heat driving both ice-cream sales and swimming-pool attendance) may drive both columns together. Furthermore, Anscombe's famous quartet proves that four wildly different datasets—a clean line, a parabola, a line with one extreme Y outlier, and a vertical cluster with one leverage point—can all share the exact same r = 0.816! Always click Open in Scatter Plot Maker in the results panel (or visit our full scatter plot maker) to inspect your coordinates visually, or check each variable's own distribution in the histogram maker.