Correlation Coefficient Calculator (Pearson r, Steps)

Free correlation coefficient calculator. Enter your X and Y data to get Pearson r, R squared, covariance, and a step by step solution with a scatter plot.

Correlation Coefficient Calculator

The Pearson correlation coefficient r measures how strongly two variables move together, on a scale from −1 to 1. Enter your paired X and Y data below to get r, R squared, the covariance, and a scatter plot with the correct line of best fit.
Separate values with commas, spaces, or new lines. Both lists must have the same number of values.

The correlation coefficient (Pearson r) tells you how strongly two variables move together, on a scale from -1 to 1. A value near 1 means they rise together, near -1 means one rises as the other falls, and near 0 means almost no linear link. Paste your paired X and Y numbers into the calculator above and you get r, R squared, the covariance, and a full worked solution with a scatter plot. Below, this page shows you how to calculate the correlation coefficient by hand, with real datasets solved step by step, so you can check the answer or learn the method.

What is the correlation coefficient?

The correlation coefficient, written as r, is a single number between -1 and 1 that measures how closely two variables follow a straight-line relationship. It answers one question: when X changes, does Y change with it, against it, or not at all?

The version almost everyone means by “the correlation coefficient” is the Pearson correlation coefficient, sometimes called Pearson’s r or the product moment correlation coefficient. Here is how to read the number:

  • r close to +1: strong positive link. As X goes up, Y goes up.
  • r close to -1: strong negative link. As X goes up, Y goes down.
  • r close to 0: little or no straight-line link between the two.

One point that trips people up: r only measures a straight-line relationship. Two variables can be tightly connected in a curved pattern and still show an r near 0. The number also says nothing about cause. A high r means the two move together, not that one makes the other happen.

What is the correlation coefficient formula?

The Pearson correlation coefficient formula is:

r = Σ(x – x̄)(y – ȳ) ÷ √[ Σ(x – x̄)² × Σ(y – ȳ)² ]

In plain words: for every data point you find how far X sits from the mean of X, and how far Y sits from the mean of Y. Multiply those two gaps for each point and add them up. That top sum is the covariance part. The bottom scales it by how spread out X and Y are on their own, which forces the result to land between -1 and 1.

The pieces you need are:

  • x̄ and ȳ = the mean (average) of the X values and the Y values.
  • Σ(x – x̄)(y – ȳ) = the sum of the products of the deviations.
  • Σ(x – x̄)² and Σ(y – ȳ)² = the sum of squared deviations for each variable.

How do you calculate the correlation coefficient by hand?

You can work out r manually in five steps. The covariance between the two variables sits right in the middle of this process, so if you understand one you understand the other.

  1. Find the mean of X and the mean of Y. Add each list up and divide by how many values there are.
  2. Find each deviation. Subtract the mean of X from every X value, and the mean of Y from every Y value.
  3. Multiply the paired deviations for each point, then add them all up. This is the top of the formula.
  4. Square the deviations for X and for Y separately, and add each column up.
  5. Put the sums into the formula. Divide the top sum by the square root of the two squared-deviation sums multiplied together.

The worked examples below run through this exact process with real numbers.

Correlation coefficient worked example (step by step)

Take the dataset X = 4.5, 4.6, 4.6, 5.1, 5.2 and Y = 1.3, 1.4, 1.7, 1.6, 1.8. Here is the full solution.

Step 1. Means. Mean of X = (4.5 + 4.6 + 4.6 + 5.1 + 5.2) ÷ 5 = 4.8. Mean of Y = (1.3 + 1.4 + 1.7 + 1.6 + 1.8) ÷ 5 = 1.56.

xyx – x̄y – ȳ(x-x̄)(y-ȳ)(x-x̄)²(y-ȳ)²
4.51.3-0.3-0.260.0780.090.0676
4.61.4-0.2-0.160.0320.040.0256
4.61.7-0.20.14-0.0280.040.0196
5.11.60.30.040.0120.090.0016
5.21.80.40.240.0960.160.0576
Sums0.190.420.172

Step 2. Apply the formula. r = 0.19 ÷ √(0.42 × 0.172) = 0.19 ÷ √0.07224 = 0.19 ÷ 0.2688 = 0.7069.

Rounded to the nearest tenth, r = 0.7. That is a strong positive relationship: as X rises, Y tends to rise too.

Correlation coefficient example with a negative result

Now try X = 34, 57, 62, 73, 96, 97 and Y = 59, 53, 55, 58, 32, 48. This one comes out negative.

Mean of X = 69.83, mean of Y = 50.83. Running the same five steps gives:

  • Σ(x – x̄)(y – ȳ) = -900.17
  • Σ(x – x̄)² = 2942.83
  • Σ(y – ȳ)² = 502.83

r = -900.17 ÷ √(2942.83 × 502.83) = -900.17 ÷ 1216.44 = -0.7399.

Rounded to the nearest tenth, r = -0.7. A strong negative relationship: higher X values line up with lower Y values.

A quick five-point example

For X = 10, 12, 8, 5, 20 and Y = 1, 15, 10, 6, 4, the calculator returns r = -0.13. The means are 11 for X and 7.2 for Y, the top sum is -16, and the two squared-deviation sums are 128 and 118.8. Dividing gives -16 ÷ √(128 × 118.8) = -16 ÷ 123.31 = -0.13. That is close to zero, so these two variables have almost no linear relationship.

What does the correlation coefficient value mean?

Once you have r, the size of the number tells you the strength of the link. Use this table to read any result, whether it came from the calculator or from your own working.

Value of rStrengthWhat it tells you
+0.9 to +1.0Very strong positiveX and Y rise together almost perfectly
+0.7 to +0.9Strong positiveClear upward trend
+0.5 to +0.7Moderate positiveNoticeable upward trend with scatter
+0.3 to +0.5Weak positiveSlight upward tendency
-0.3 to +0.3Little to noneNo useful straight-line link
-0.5 to -0.3Weak negativeSlight downward tendency
-0.7 to -0.5Moderate negativeNoticeable downward trend with scatter
-0.9 to -0.7Strong negativeClear downward trend
-1.0 to -0.9Very strong negativeX and Y move in opposite directions almost perfectly

So from a set like {-0.9, -0.7, -0.3, 0, 0.3, 0.7, 0.9}, the strongest relationship belongs to the value furthest from zero in either direction. Both -0.9 and 0.9 are equally strong. The only difference is the direction of the link, not its strength.

What is R squared, and how is it different from r?

R squared (R²) is simply the correlation coefficient multiplied by itself. If r = 0.7, then R² = 0.49. It is always between 0 and 1 and it drops the plus or minus sign.

The useful part is how you read it: R² tells you the share of the variation in Y that lines up with X. An R² of 0.49 means about 49 percent of the movement in Y is accounted for by its straight-line link with X. The rest comes from other factors. Many stats classes report R² alongside a linear regression line, which is why the two show up together so often.

Does a high correlation mean one variable causes the other?

No. This is the single most common mistake with correlation. A strong r only means the two variables move together in the data you measured. It does not prove that one causes the other.

Ice cream sales and drowning deaths are strongly correlated, for example, but ice cream does not cause drowning. Hot weather drives both up at the same time. Whenever you report a correlation, treat it as a signal worth investigating, not as proof of cause.

How do you find the correlation coefficient on a scatter plot?

A scatter plot gives you a fast visual read before you calculate anything. Plot each pair as a dot, then look at the cloud of points:

  • Points sloping up from left to right suggest a positive r.
  • Points sloping down suggest a negative r.
  • A tight, near-straight line means r is close to 1 or -1.
  • A round, shapeless cloud means r is near 0.

The calculator above draws this scatter plot for you and adds the line of best fit, so you can see the pattern and read the exact r value at the same time.

Frequently asked questions

Can the correlation coefficient be greater than 1?
No. By design r is always between -1 and 1. If your hand calculation gives a number outside that range, there is an arithmetic slip somewhere in the deviations or the square roots.

What is a good correlation coefficient?
It depends on the field. In physics an r of 0.9 might be expected, while in social science an r of 0.4 can be meaningful. As a general guide, anything past 0.7 or below -0.7 is usually treated as a strong relationship.

Is r the same as the slope of the line?
No. They share a sign, so both are positive or both negative, but they measure different things. The slope tells you how many units Y changes per unit of X. The correlation coefficient tells you how tightly the points hug that line.

How many data pairs do I need?
You need at least two pairs to get a value, but two points always give r of exactly 1 or -1, which is meaningless. For a result you can trust, aim for a reasonable sample, and more is better.

Try these next

  • Kushagra Verma

    Researcher | BSc. CS + Financial Math

    Kushagra Verma is a researcher with a BSc in Computer Science and Financial Mathematics, focusing on data-driven analysis and real-world applications.

  • Muhammad Abdullah Arshad

    MPhil Statistics Scholar

    M. Abdullah Arshad is an MPhil Statistics scholar and Google-certified data analyst specializing in statistical analysis, data mining, and time series modeling.