How the correlation coefficient calculator works
Pearson's correlation coefficient answers one question: when x moves, how reliably does y move with it, in a straight line? The recipe has four steps, and the calculator runs them on your own numbers and shows each one. First it finds the mean of your x values and the mean of your y values. Then, for every pair, it measures how far x sits from its mean and how far y sits from its mean, and multiplies the two deviations together: a pair where both are above their means (or both below) gives a positive product, a pair where they disagree gives a negative one. Adding those products up gives the covariance numerator, the raw measure of moving-together. Finally it divides by the square root of the two sums of squared deviations, which is the largest that numerator could possibly be, so the answer always lands between -1 (a perfect downhill line) and +1 (a perfect uphill line), with 0 meaning no straight-line pattern at all.
The calculator also fits the least squares line through your points and lists each residual, the observed y minus the y the line predicted, which is the part of y the line did not explain. This page and the least squares regression calculator are deliberate siblings: that page predicts (feed it an x, it hands back a y), while this page measures how much a straight line deserves your trust in the first place. The two run the same arithmetic underneath, so they can never disagree.
The formula
Here x̄ and ȳ are the means of the two lists and the sums run over all n pairs. The numerator is the co-variation: how much x and y stray from their means in the same direction at the same time. The denominator is the same quantity's ceiling, what the numerator would be if the pairing were perfect, which is why r is a pure number with no units: measure height in inches or centimeters and r does not change, because scaling a variable stretches the numerator and the denominator by the same factor. Squaring r gives r2, the share of the variation in y that the straight-line relationship accounts for.
Worked example
Five students report hours studied x = 1, 2, 3, 4, 5 and quiz scores y = 2, 4, 5, 4, 6. The means are x̄ = 3 and ȳ = 4.2. The deviation products are (−2)(−2.2) + (−1)(−0.2) + (0)(0.8) + (1)(−0.2) + (2)(1.8) = 4.4 + 0.2 + 0 − 0.2 + 3.6 = 8. The squared deviations sum to Σ(x − x̄)² = 4 + 1 + 0 + 1 + 4 = 10 and Σ(y − ȳ)² = 4.84 + 0.04 + 0.64 + 0.04 + 3.24 = 8.8. So r = 8 ⁄ √(10 × 8.8) = 8 ⁄ 9.3808 ≈ 0.8528, a strong positive correlation, and r2 ≈ 0.7273: hours studied account for about 72.7% of the variation in these scores, and the other 27.3% is everything else about a quiz and a life. The fitted line is ŷ = 0.8x + 1.8, and its residuals (−0.6, 0.6, 0.8, −1, 0.2) sum to exactly zero. Paste those two lists above and you get every one of these numbers.
What counts as strong (and who gets to say)
The usual ladder reads: 0.9 and above very strong, 0.7 to 0.9 strong, 0.4 to 0.7 moderate, 0.2 to 0.4 weak, below 0.2 little to none, with the same rungs on the negative side. Those bands are conventions, not verdicts, and they vary by field more than most textbooks admit. In psychology, where every measurement passes through a human being, an r of 0.3 can be a solid, publishable effect. In a physics lab, where the relationship between voltage and current is supposed to be a law, that same 0.3 usually means a loose cable. So when this page calls your r "moderate," read it as "moderate by the common convention," and then ask the better question: is it strong for data like yours? A useful companion habit: square it. An r of 0.5 sounds respectable and explains 25% of the variation, which keeps everyone appropriately humble. And if you need to know whether an r this size could plausibly arise by chance at your sample size, that is a significance question, which is the p-value calculator's department, not this page's.
Correlation is not causation (here is what else it could be)
A genuine, well-measured correlation between x and y has at least four explanations, and r cannot tell them apart. Maybe x really does cause y. Maybe y causes x, which is reverse causation: cities with more police have more recorded crime, mostly because crime brings police, not the other way round. Maybe a lurking third variable drives both: ice cream sales correlate beautifully with drowning deaths, and the cause of both is summer, when people eat ice cream and swim. Or maybe it is chance, a pattern in this sample that a larger one would wash out, which is why small n deserves extra suspicion. None of this makes correlation useless: it is how relationships get noticed in the first place. It just means the coefficient is the start of the investigation, not the conclusion. Sorting the four explanations apart takes controlled experiments or careful causal reasoning, and no value of r, however beautiful, can do that work by itself.
The Anscombe warning: four datasets, one r
In 1973 the statistician Francis Anscombe built four small datasets that have been keeping analysts honest ever since. All four share nearly identical summary statistics: the correlation is about 0.816 in every one, and the fitted line is essentially ŷ = 0.5x + 3 in every one. Plotted, they look nothing alike: one is an ordinary noisy trend, one is a clean curve that a straight line insults, one is a tight line with a single outlier dragging the fit, and one is a vertical stack of points with one far-off pair inventing the whole relationship. Same r, four completely different stories. The lesson generalizes: r measures linear association only. A perfect curve can score near zero (x = −2, −1, 0, 1, 2 against y = 4, 1, 0, 1, 4 is a flawless parabola with r exactly 0, because the upslope and downslope cancel), and one outlier can manufacture or destroy an impressive coefficient. So always look at the shape of your data, not just the number: the residuals table this page prints is a plot you can read without graph paper, and a standard deviation check on each list will flag the stray value that is quietly running the show.