Pearson Correlation Coefficient Calculator
Paste two columns of numbers and get the Pearson correlation r, r², covariance, a significance test (t-statistic and two-tailed p-value), and a scatter plot with the full step-by-step working. Matched to scipy.stats.pearsonr, runs entirely in your browser — no signup, nothing uploaded.
How it works
The Pearson product-moment correlation coefficient r measures the strength and direction of the linear relationship between two paired variables. It runs from −1 (a perfect decreasing line), through 0 (no linear association), to +1 (a perfect increasing line). The definition is the one in the NIST/SEMATECH e-Handbook of Statistical Methods §1.3.5.13.
For n paired observations, with means x̄ = (Σxᵢ)/n and ȳ = (Σyᵢ)/n, the coefficient is the sum of cross-products of the deviations divided by the root of the product of the squared deviations:
r = Σ(xᵢ−x̄)(yᵢ−ȳ) / √( Σ(xᵢ−x̄)² · Σ(yᵢ−ȳ)² ) = Sxy / √(Sxx · Syy)
The tool computes this in four steps:
- Means and deviations. It averages each column, then subtracts the mean from every value to get the deviations
(xᵢ−x̄)and(yᵢ−ȳ). - Sums. It accumulates
Sxy,Sxx, andSyyfrom the deviation table. If Sxx or Syy is zero — a constant column — r is undefined, so the tool shows a clear message instead of a divide-by-zero. - r and r². The correlation is Sxy / √(Sxx·Syy), and r² (the coefficient of determination) is r squared — the share of variance in one variable explained by a linear fit on the other. Covariance is Sxy/(n−1) for a sample (or Sxy/n for a whole population); r itself is unaffected by that choice.
- Significance. Under the null hypothesis that the true correlation is zero,
t = r√(n−2)/√(1−r²)follows a Student-t distribution withdf = n−2. The two-tailed p-value is the regularized incomplete beta functionI_x(df/2, 1/2)atx = df/(df+t²), the exact identity SciPy uses.
As a credibility check the calculator also recomputes r a second way — the raw-score formula [n·Σxy − ΣxΣy] / √(…) — and confirms both routes agree to floating-point precision, matching scipy.stats.pearsonr. Pearson's r assumes a roughly linear relationship; for ranked or monotonic-but-curved data, a rank correlation such as Spearman fits better. And a strong r is evidence of association, never of causation on its own.
Worked examples
Frequently asked questions
Sources & references
- NIST/SEMATECH e-Handbook of Statistical Methods §1.3.5.13 — the product-moment correlation coefficient
- scipy.stats.pearsonr — reference implementation for r and the two-tailed p-value
- NIST e-Handbook §1.3.6.7.2 — critical values of the Student-t distribution
The formulas on this page were last cross-checked against these sources on 2026-06-10. Pearson's r is a stable mathematical definition, so this tool needs no rate or schedule updates — only the worked examples are periodically re-reconciled against SciPy.
Related tools
Comments & feedback
Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.
Found a bug, edge case, or want to suggest an improvement?
Email me at [email protected] — most fixes ship within 24 hours.