Correlation coefficient calculator

Paste paired x and y values to find Pearson's r or Spearman's rho, test whether it's significant and see every step.

  • Free, no sign-up
  • Step-by-step working
  • Runs in your browser

Separate values with commas, spaces or new lines. The first x pairs with the first y, and so on. You can paste two spreadsheet columns.

Method

How to use the correlation coefficient calculator

  1. Paste your x values in the first box and the matching y values in the second, in the same order.
  2. Choose Pearson for a straight-line relationship between measured values, or Spearman for ranks, ratings or data with outliers.
  3. Pick the alternative hypothesis and significance level for the test (two-tailed at α = 0.05 is the usual choice).
  4. Optionally name the variables so the chart and explanation use them, then click Calculate correlation.
  5. Read r, r², the p-value and the plain-English summary, and check the scatter plot for curves or outliers.

Correlation coefficient formula

Pearson's correlation coefficient compares how x and y vary together with how much each varies on its own:

r = Σ(x − x)(y − y)Σ(x − x)2 · Σ(y − y)2 = SxySxx Syy

To test whether the correlation differs from zero, convert r to a t statistic with n − 2 degrees of freedom:

t = r n − 21 − r2

r
The sample correlation coefficient, between −1 and 1
x, y
The means of x and y
Sxy
The sum of the products of the deviations, which is positive when x and y tend to be above (or below) their means together
Sxx, Syy
The sums of squared deviations of x and of y
n
The number of (x, y) pairs
ρ
The population correlation, which the test compares with 0. Spearman's rho is Pearson's r computed on the ranks of x and y

Worked example

Five students report hours of sleep (x) and a quiz score out of 5 (y): (1, 2), (2, 4), (3, 5), (4, 4), (5, 5). How strongly are they correlated?

  1. Find the means
    x = 155 = 3, y = 205 = 4
  2. Sum the products and squares of the deviations
    Sxy = (−2)(−2) + (−1)(0) + 0(1) + 1(0) + 2(1) = 6
    Sxx = 4 + 1 + 0 + 1 + 4 = 10, Syy = 4 + 0 + 1 + 0 + 1 = 6
  3. Divide
    r = 610 × 6 = 0.7746
  4. Test it: t with 5 − 2 = 3 degrees of freedom
    t = 0.7746 31 − 0.6 = 2.1213, p = 0.1240

What it means: r = 0.77 is a strong positive correlation, and r² = 0.60, so a straight line on sleep explains 60% of the variation in scores. But with only five students, the p-value of 0.124 is above 0.05, so the sample is too small to rule out that the pattern happened by chance.

How to interpret a correlation coefficient

  • The sign gives the direction. Positive r means y tends to rise as x rises; negative r means y tends to fall.
  • The size gives the strength of the linear relationship: 0 means no linear relationship, ±1 means the points lie exactly on a line.
  • r² is the share of the variation in y explained by a straight line on x.
  • The p-value tells you whether the correlation could plausibly be zero in the population. With large samples, even weak correlations become significant, so judge the size too.
  • Look at the plot. A curved relationship can have r near 0, and one outlier can create or hide a strong correlation.

To fit and draw the trend line itself, use the scatter plot maker, which gives the least-squares equation alongside the chart.

Frequently asked questions

What is a good correlation coefficient?

It depends on the field. As a rough guide, |r| below 0.2 is very weak, 0.2–0.4 weak, 0.4–0.6 moderate, 0.6–0.8 strong and above 0.8 very strong. In physics or engineering, anything below 0.9 may be disappointing; in psychology or social science, r = 0.3 can be a meaningful finding. Always look at the scatter plot as well.

What is the difference between Pearson and Spearman correlation?

Pearson’s r measures how closely the points follow a straight line and uses the actual values. Spearman’s rho ranks each variable first and then computes Pearson’s r on the ranks, so it measures any consistently increasing or decreasing (monotonic) relationship. Spearman is less affected by outliers and works for ordinal data like ratings.

Does correlation mean causation?

No. A strong correlation shows that two variables move together, not that one causes the other. Both might be driven by a third factor (ice cream sales and drownings both rise in summer), or the direction of cause might be the reverse of what you expect. Establishing cause usually needs a controlled experiment.

What is the difference between r and r²?

The correlation coefficient r ranges from −1 to 1 and shows both the strength and direction of a linear relationship. Its square, r², is the coefficient of determination: the proportion of the variation in y that a straight line on x explains. For example, r = 0.8 gives r² = 0.64, so 64% of the variation is explained.

How is the p-value for a correlation calculated?

Under the null hypothesis of no correlation, the statistic t = r√(n − 2) / √(1 − r²) follows a t distribution with n − 2 degrees of freedom. The p-value comes from that distribution. A small p-value means a correlation this strong would be unlikely if there were truly no relationship. You can check the conversion with the p-value calculator.

How do I calculate the correlation coefficient in Excel or Google Sheets?

Use =CORREL(A2:A20, B2:B20) or =PEARSON(A2:A20, B2:B20) for Pearson’s r. For Spearman’s rho, rank each column with =RANK.AVG() and then apply CORREL to the ranks. This calculator gives the same r plus the significance test and confidence interval.

Last reviewed November 11, 2026