Correlation calculator

Pearson and Spearman at once, because they answer different questions — one asks how straight the relationship is, the other only whether it goes one way. Nothing you type here leaves your browser — it is worked out on your own device, so there is nothing to send and nothing to log.

Two coefficients, two different questions

Pearson measures how close your points lie to a straight line. Spearman measures whether y rises when x rises, by any shape at all.

On the numbers this page opens with — y is roughly x squared — Spearman is 1, because every time x goes up so does y, without exception. Pearson is 0.9749, because a parabola is not a line. Neither is wrong. They were asked different things.

A calculator that offers only Pearson will tell you a perfect relationship is imperfect, and it will not tell you that the imperfection is the shape rather than the strength.

Ties, and where implementations disagree

Spearman is Pearson applied to the ranks, so it depends entirely on how you rank. The question is what tied values get, and the answer is that they share the average of the positions they span: 1, 2, 2, 3, 3, 3, 4 ranks as 1, 2.5, 2.5, 5, 5, 5, 7.

Ranking tied values in the order they happen to be typed gives a coefficient that is wrong on any dataset with a repeated value — which is most real data — and it stays entirely plausible while being wrong. This page averages them, and shows the ranks so you can check.

And the thing correlation is not

It is not causation, which everybody knows and which is not the interesting half. The interesting half is that a correlation coefficient is one number standing in for an entire scatter plot, and that trade loses more than people expect.

Four datasets can share a mean, a variance, a correlation and a regression line and look nothing alike. That is not a thought experiment: it is Anscombe's quartet, published in 1973, and this site draws it.

Plot your data before you trust a coefficient about it.

Where to go next