Math calculator

Correlation Coefficient Calculator

Pearson, Spearman and Kendall — and why one number is never enough.

How strong is the relationship — and is it a line?

A genuine, noisy linear relationship — the only one of the four a correlation describes honestly.

Pearson's r over 11 pairs

0.816421

r² = 0.666542 — 66.65% of the variation in y is accounted for by a straight line in x. p = 0.002170.

57.510510xy

Pearson r

0.816421

straight-line strength

Spearman ρ

0.818182

monotone strength, on ranks

Kendall τ-b

0.636364

concordant minus discordant pairs

Covariance

5.501000

unstandardised, so unit-dependent

Least-squares line

y = 3.00009 + 0.50009x

Slope standard error

0.11791

t = 4.2415 on 9 df

Residual standard error

1.23660

Pearson says 0.8164; Spearman says 0.8182, and they broadly agree. Agreement between the two is weak evidence that a straight line is a fair summary — weak, not strong, because Anscombe’s first and fourth datasets both agree closely while only one of them contains a relationship. Look at the scatter above regardless; that is the only check that cannot be fooled.
Switch between the four presets and watch what does not move. All four have r ≈ 0.816, r² ≈ 0.667, a mean x of exactly 9, a mean y of 7.50, and the same fitted line y = 3.00 + 0.500x — agreeing to three decimal places. The scatter plot changes completely. Every classical summary of a relationship can be identical across datasets that have nothing in common, which is why the plot is not optional.

What this tool shows

Four datasets can share an r of 0.816, identical means, identical variances and the same fitted line — and look nothing alike. That is Anscombe’s quartet, and it is loaded here by default. Spearman does tell them apart, which makes the gap between the two coefficients a free non-linearity check.

  • Pearson’s r for straight-line strength
  • Spearman’s ρ for any monotone relationship
  • Kendall’s τ-b, which handles ties correctly
  • Covariance, the unstandardised version
  • The least-squares line, its slope error and p-value
  • Anscombe’s quartet built in, switchable
Three coefficients Anscombe built in Scatter plot always shown Tie-correct ranks

Anscombe IV: delete one point and r goes from 0.817 to undefined.

Updated 8 September 2026 · Works in any browser, no installation

A correlation coefficient measures how tightly two variables move together, on a scale from −1 to +1. What it does not do is tell you the shape of the relationship, and that is not a limitation to note in passing — it is the reason correlations get misread.

At a glance

Formula shown
Pearson r = Σ(x − x̄)(y − ȳ) ÷ √(Σ(x − x̄)²·Σ(y − ȳ)²) — computed from centred sums, never from (nΣxy − ΣxΣy), which loses precision on data far from the origin. Spearman is that same formula applied to ranks. r² is the share of variance a straight line accounts for. The significance test is t = r√(n − 2)/√(1 − r²) on n − 2 degrees of freedom.
Scenario support
Checking whether two measurements move together; screening variables before a regression; validating a proxy measure; testing a monotone but curved relationship with Spearman; comparing rankings with Kendall.
Educational estimate
Planning support from the values you enter — not professional advice.

Four datasets, one correlation, nothing in common

Francis Anscombe built four datasets in 1973 to make a point that no amount of arguing had made. Load them in the tool above and switch between them.

All four agree to three decimal places on every classical summary. r = 0.816. r² = 0.667. Mean x = 9 exactly. Mean y = 7.50. Variance of y = 4.12. Fitted line y = 3.00 + 0.500x. Everything a statistical report normally contains is the same.

The scatter plots have nothing in common. The first is a genuine noisy line. The second is a clean parabola — a perfect relationship that a linear measure cannot see. The third is a straight line to seven figures with one outlier, and that single point drags r down from 0.99999655 to 0.816. The fourth has no relationship at all: ten points share the same x, and one point at x = 19 manufactures the entire correlation. Delete it and r is undefined, because x never varies.

Here is the part usually left out, and it is the useful part. Spearman’s ρdoes separate them: 0.818, 0.691, 0.991, 0.500. Where Pearson reports four identical numbers, Spearman reports four distinctly different ones.

That gives you an automatic check that costs one extra calculation. When Pearson and Spearman differ substantially, the relationship is not linear, or a small number of points are doing most of the work. Neither coefficient tells you which — but the disagreement tells you to look, and the tool flags it.

It is still not a substitute for the plot. Anscombe’s first and fourth datasets have Pearson and Spearman in reasonable agreement, and only one of them contains a relationship. The disagreement check catches many failures cheaply; the scatter plot catches all of them, which is why the tool draws it before it reports anything.

Which coefficient answers your question

The three measure genuinely different things, and picking by habit rather than by question is how a real relationship gets reported as absent.

Pearson’s r asks: how close are these points to a straight line? It is the default and it is the right choice for roughly linear relationships between roughly symmetric variables. It is sensitive to outliers, because it works with the actual distances.

Spearman’s ρ asks: does y rise when x rises? It works on ranks, so it detects any monotone relationship regardless of shape — and a perfect curve gets ρ = 1 where Pearson reports something considerably less. Replacing values with ranks also caps the influence of an outlier at one rank position, which makes it far more robust.

Kendall’s τ asks: what share of pairs agree on direction? It counts, for every pair of observations, whether both variables move the same way. That interpretation is unusually concrete — a τ of 0.6 means 80% of pairs are concordant — and it behaves better than Spearman on small samples and heavily tied data. It is systematically smaller than ρ on the same data, which is not a disagreement but a difference of scale.

Use Spearman or Kendall when the data is ordinal — survey responses, rankings, grades. Pearson on a five-point Likert scale is treating “agree” minus “neutral” as a real distance equal to “neutral” minus “disagree”, which the scale does not promise.

One implementation warning, because it is invisible. Spearman is often computed with the shortcut 1 − 6Σd²/(n(n² − 1)). That formula is only valid with no tied values. With ties it is silently wrong — on one small example here it returns 0.2321 where the correct answer is 0.1989 — 16.7% too high, with nothing to indicate a problem. This page computes Spearman as Pearson on midranks, which is correct either way.

Correlation and causation, stated usefully

“Correlation does not imply causation” is true, universally repeated, and too vague to act on. The useful version is the list of specific things that produce a correlation without a causal link.

A common cause. Ice cream sales and drowning deaths correlate because both rise with temperature. Neither causes the other; a third variable drives both. This is the most common case by far, and the fix is to measure the third variable and control for it.

Reverse causation. The relationship is real and runs the other way. Hospitals correlate with illness. The correlation is symmetric; causation is not, and a coefficient cannot distinguish direction.

Selection effects. Correlations can be created by how the sample was chosen. Among admitted students, test scores and interview scores often correlate negatively even when they are independent in the applicant pool — because admission required doing well on at least one, so anyone weak on the first must have been strong on the second. This one is genuinely counter-intuitive and appears constantly in observational data.

Coincidence. Test enough variable pairs and strong correlations appear by chance. With 100 unrelated variables there are 4,950 pairs, and at a 5% threshold roughly 250 will look significant. This is why a correlation found by searching needs a much stronger threshold than one predicted in advance.

Aggregation. Correlations between group averages are usually far stronger than the same correlation between individuals, and applying one to the other is the ecological fallacy. Country-level data is especially prone to this — a strong relationship across 40 national averages can be near zero within every one of those countries.

What a correlation genuinely provides is a screening tool and a prediction. If x and y correlate, x helps predict y whether or not it causes it. That is worth something on its own, and it is a claim you can defend.

Reading r without overstating it

Four habits that keep an r honest.

Square it before interpreting the strength. r = 0.5 sounds like half a relationship; it accounts for 25% of the variance. r = 0.7 accounts for 49%. The coefficient is on a scale that flatters weak relationships, and r² is the number that answers “how much does knowing x help?”

Do not use fixed strength labels. “0.7 is strong” depends entirely on the field. An r of 0.3 is a substantial effect in psychology and unacceptably poor for a calibration instrument. Compare against what is typical in your domain, not against a table.

Statistical significance is not strength. At n = 1000, an r of 0.07 is significant at the 1% level — and it accounts for half a percent of the variance. With enough data every nonzero correlation becomes significant. Report the coefficient and the sample size together; a p-value alone hides which one you have.

Restricting the range shrinks r. Compute a correlation only among high scorers and it drops sharply, because you have removed most of the variation it needs. This is why validity coefficients look weak when computed on people who were selected using the very test being validated — a structural artefact, not evidence that the test fails.

For the fitted line itself, its uncertainty and its residual behaviour, the linear regression calculator goes further than the summary shown here.

Controlling for a third variable

The most common cause of a correlation without a causal link is a shared third variable. Partial correlation is the arithmetic that removes it, and it is worth knowing because it turns a caveat into a calculation.

A partial correlation is the correlation between x and y after removing what z explains of both. Regress x on z, regress y on z, then correlate the two sets of residuals. What is left is the association that z does not account for.

The classic result is that it can collapse to nothing. Ice cream sales and drowning deaths correlate strongly; control for temperature and the partial correlation falls near zero. That is a direct demonstration that the original association carried no information about a link between them.

It can also go the other way, which is the surprising case. Two variables can be uncorrelated overall and strongly correlated once a third is held fixed — a suppressor variable was hiding the relationship. So a zero correlation is not evidence of no relationship any more than a strong one is evidence of a causal link.

The limits are real and worth stating. Controlling for z only works if you measured z, and measured it well — a noisy measurement removes only part of its influence and leaves residual confounding that looks like a genuine effect. And controlling for a variable that sits between x and y on the causal path removes the very effect you were trying to measure.

Which is the honest summary: partial correlation controls for the confounders you thought of and measured. That is a real advance on doing nothing, and it is not the same as controlling for confounding.

Sources and methodology

References for the quartet and the rank statistics.

Method. Pearson is computed from centred sums rather than the algebraically identical (nΣxy − ΣxΣy) form, which subtracts two large nearly-equal numbers and can lose most of its significant digits — or return an |r| above 1 — on data far from the origin. Ranks use midranks, so Spearman is correct under ties where the familiar 6Σd² shortcut is not; Kendall is tau-b for the same reason. A constant variable returns undefined rather than zero, because “no information” and “no association” are different findings. The suite asserts that all four Anscombe datasets agree on r, r², both means and the fitted line to three decimals while their Spearman values differ by up to 0.49, that the shortcut disagrees with the correct Spearman under ties, and that the centred and computational forms diverge on offset data. That engine is verified on every change against 79 assertions. The count and the per-case breakdown are published on the formula verification page.

Related calculators

Where this goes next:

Linear RegressionThe least-squares line with r and r² — and the regression of x on y beside it, because those are two different lines rather than one line rearranged.
CovarianceSample and population covariance with a unit multiplier that shows why the magnitude is unreadable — rescaling x multiplies the covariance while leaving the correlation untouched.
Standard DeviationSample and population standard deviation, plus variance, mean, median, quartiles, z-scores, outliers, and confidence intervals.
p-valueA p-value from a t or z statistic, one- or two-tailed — with a panel that holds an effect fixed and grows the sample, so you can watch significance appear from nothing but n.
VarianceSample and population variance from your data, with a live simulation that shows exactly how much the wrong divisor costs — 20% low at n = 5, closing as the sample grows.
Mean, Median and ModeAll three centres marked on your own data, every mode rather than just the first, and the mean-median gap read as a direct measure of skew.

More in Math, or browse all calculators.

Educational use disclaimer

An educational tool. A correlation measures association, not causation, and no coefficient distinguishes a causal link from a common cause, reverse causation, a selection effect or a coincidence.

How we calculate · Found an error? email us

Authorship & verification

Written and maintained by , a business operator who builds spreadsheet-based calculators.

What's changed (4 updates)

Published 8 September 2026

  1. Published a correlation calculator that loads Anscombe's quartet as its default state rather than describing it in prose: four datasets agreeing to three decimal places on r, r-squared, both means and the fitted line, with scatter plots that have nothing in common.
  2. Reports Spearman and Kendall alongside Pearson, because Spearman does separate the quartet — 0.818, 0.691, 0.991, 0.500 — which makes a Pearson-Spearman disagreement a free non-linearity check.
  3. Computes Pearson from centred sums rather than the algebraically identical computational formula, which loses most of its significant digits on data far from the origin and can return a correlation outside minus one to plus one.
  4. Uses midranks for Spearman, so it stays correct under ties where the familiar six-sigma-d-squared shortcut is silently wrong — on one small example the shortcut returns 0.2321 against a correct 0.1989.

Add this calculator to your site

Responsive embed — and private: nothing your visitors type leaves their browser.