Menu

Correlation Coefficient Calculator

Pearson r from your data, exact as a radical, with its strength and the working behind it.

By Nethanel Bar, Co-founder & CEO

Last updated

Want to solve these without the calculator?

The Coddy math course teaches the method itself - you work each step on an interactive board and get told exactly where a move went wrong.

r measures how closely points follow a straight line

The correlation coefficient r is a single number between -1 and 1. Its sign is the direction of the trend: positive when y tends to rise as x rises, negative when it tends to fall. Its size is how tightly the points hug a straight line: 1 or -1 when every point sits on one line, 0 when there is no straight-line trend at all. It carries no units, so it does not change when you measure x in centimetres instead of metres.

The calculation is the one a statistics course asks you to show. Make a table with x, y, xy, x² and y², add each column, and put the sums into r = (nΣxy minus ΣxΣy) divided by the square root of (nΣx² minus (Σx)²) times (nΣy² minus (Σy)²). This page prints that table and the filled-in formula under the answer, so the number arrives with its working.

The answer is exact. The square of r is always a fraction on data you can type, so r itself is the square root of a fraction with a sign attached, and that is what this page prints: √15/5 for the textbook set rather than 0.77, which is two digits of it. The decimal sits beside the radical, and the strength label reads it against the thresholds stated below.

How to read r

  • The sign is the direction and the size is the strength. r = -0.95 is a stronger relationship than r = 0.6; it just runs the other way.
  • This page labels |r| of 0.7 or more strong, 0.4 up to 0.7 moderate, 0.1 up to 0.4 weak and under 0.1 no linear correlation. These are a common convention, not a rule; fields set their own bars.
  • r² is the share of the variation in y that the line of best fit accounts for. r = √15/5 gives r² = 0.6: the line explains 60% of the variation.
  • r only measures straight-line relationships. Points lying exactly on y = x² from x = -2 to 2 have r = 0.
  • One outlier can change r completely. Add the point (10, 0) to the textbook set and r goes from about 0.7746 to about -0.5529.
  • r does not change when you rescale either variable or swap x with y. The line of best fit does change when you swap them; r does not.

How to calculate the correlation coefficient by hand

  1. Build the sums table

    For every point write x, y, xy, x² and y², then add each column and count the points. For x = 1, 2, 3, 4, 5 and y = 2, 4, 5, 4, 5 that gives n = 5, Σx = 15, Σy = 20, Σxy = 66, Σx² = 55 and Σy² = 86.

  2. Work out the top

    nΣxy minus ΣxΣy = 5 × 66 minus 15 × 20 = 30. Its sign is the sign of r.

  3. Work out the two brackets underneath

    nΣx² minus (Σx)² = 275 minus 225 = 50, and nΣy² minus (Σy)² = 430 minus 400 = 30. Both are always positive unless every x or every y is the same.

  4. Divide and simplify

    r = 30 / √(50 × 30) = 30 / √1500 = 30 / (10√15) = √15/5. As a decimal that is about 0.7746, a strong positive correlation.

Reading r at a glance

The labels are the ones this calculator prints. r² is r multiplied by itself, so the sign disappears.

rLabelr²What the scatter plot looks like
1perfect positive1Every point on one rising line
0.9strong positive0.81A narrow band climbing to the right
0.7strong positive0.49A clear upward band with some spread
0.5moderate positive0.25An upward trend with a lot of scatter
0.2weak positive0.04A tilt you would miss without the number
0.05no linear correlation0.0025A shapeless cloud, or a curve
-0.8strong negative0.64A clear band falling to the right
-1perfect negative1Every point on one falling line

Worked examples

The textbook set

plain
x: 1, 2, 3, 4, 5; y: 2, 4, 5, 4, 5

The top of the formula is 30 and the brackets underneath are 50 and 30, so r = 30 / √1500 = √15/5, about 0.7746. r² = 0.6 exactly. The label is strong positive, and the line of best fit is y = 0.6x + 2.2.

A strong negative correlation

plain
x: 1, 2, 3, 4, 5, 6; y: 10, 8, 9, 5, 4, 2

The top is -168 and the brackets are 105 and 296, so r = -168 / √31080 = -2√7770/185, about -0.9529. r² = 168/185, about 0.9081. As x goes up, y reliably goes down; the one point that breaks the pattern, (3, 9), is not enough to weaken it much.

A weak correlation

plain
x: 1, 2, 3, 4, 5; y: 3, 1, 4, 1, 5

r = √2/4, about 0.3536, and r² = 0.125, so a straight line accounts for an eighth of the variation in y. The label is weak positive: there is an upward tilt, but a scatter plot would show mostly noise.

A perfect relationship with r = 0

plain
x: -2, -1, 0, 1, 2; y: 4, 1, 0, 1, 4

Every point lies on y = x², and yet r = 0 exactly. The top of the formula is 5 × 0 minus 0 × 10 = 0: the falling left half cancels the rising right half. r measures straight-line relationships only, which is why the scatter plot comes first.

What one outlier does

plain
x: 1, 2, 3, 4, 5, 10; y: 2, 4, 5, 4, 5, 0

This is the textbook set with one extra point at (10, 0). r drops from about 0.7746 to -52√8845/8845, about -0.5529: the single point is far enough out to reverse the sign. The same thing works in the other direction: x = 1 to 5 with y = 3, 1, 4, 1, 5 has r ≈ 0.3536, and adding (12, 12) lifts it to about 0.9084.

Common mistakes

  • Squaring the sum instead of summing the squares. Σx² for x = 1 to 5 is 55; (Σx)² is 225. Mixing them up can give an r above 1, which is impossible.
  • Reading r = 0 as no relationship. It means no straight-line relationship; the points can still lie exactly on a curve.
  • Treating a strong r as evidence of cause. Two quantities can rise together because a third drives both, or by coincidence.
  • Comparing r values by their sign. -0.9 is stronger than 0.6. Compare sizes, and read the sign separately as the direction.
  • Quoting r without looking at the plot. One outlier can flip the sign, and a curve can hide behind a high value.
  • Rounding r and then squaring it. r ≈ 0.77 gives 0.5929, but r² is exactly 0.6 for the textbook set. Square the exact value.

Correlation coefficient FAQ

How do I calculate the correlation coefficient?
Make a table with x, y, xy, x² and y² for every point and add each column. Then r = (nΣxy minus ΣxΣy) / √((nΣx² minus (Σx)²)(nΣy² minus (Σy)²)). For x = 1 to 5 and y = 2, 4, 5, 4, 5 that is 30 / √(50 × 30) = √15/5, about 0.7746. Paste your own columns above and the page fills the formula in the same way.
What is a strong correlation coefficient?
This calculator calls |r| of 0.7 or more strong, 0.4 up to 0.7 moderate, 0.1 up to 0.4 weak, and under 0.1 no linear correlation. Those are common textbook thresholds, not universal ones: in a physics lab 0.9 can be disappointing, while in social science 0.4 can be a notable result.
What is the difference between r and r squared?
r has a sign and r² does not. r tells you direction and strength; r² tells you the share of the variation in y that the line of best fit accounts for. r = 0.7746 gives r² = 0.6, meaning the line explains 60% of the variation and leaves 40% as scatter.
Can the correlation coefficient be more than 1?
No. r always lies between -1 and 1 and reaches either end only when every point is on one straight line. An answer above 1 means a sum is wrong, most often Σx² computed as (Σx)².
Does a high correlation mean one thing causes the other?
No. It means the two move together in this data. A third factor can drive both, as hot weather drives both ice cream sales and swimming accidents, or the cause can run the other way. Showing cause takes an experiment or an argument about the mechanism.
Is this the Pearson or the Spearman correlation?
Pearson's r, the usual correlation coefficient, which measures how well a straight line fits the values themselves. Spearman's coefficient applies the same formula to the ranks of the values instead, which makes it measure any steadily rising or falling relationship and makes it less sensitive to outliers.
Why is r shown as a square root?
Because that is its exact value. r² is always a fraction on data you can type, so r is the square root of that fraction with a sign: √15/5 for the textbook set. The decimal 0.7746 is printed beside it as an approximation, and it is what the strength label reads.
How many points do I need?
At least three here. With two points r is always 1 or -1, because a line passes through any two points, so the number says nothing about the data. Even with a handful of points r can swing a lot, so treat an r from five points as a rough reading.

More math tools

Coddy programming languages illustration

Learn math with Coddy

GET STARTED