Calcist

Style

Buttons

Spacing

How much to show

Decimal places

Text size

Correlation calculator

Paste paired x and y values to get the Pearson correlation r, r², a significance test with t and p, and Spearman's rank correlation.

Private: calculated on your device. Nothing you type is sent anywhere.

Next: Want the line of best fit too? Use the regression calculator. Need the covariance? Try the covariance calculator.

How the correlation coefficient is calculated

Pearson's r measures how closely the points follow a straight line. It runs from −1 (a perfect downhill line) through 0 (no straight-line pattern) to +1 (a perfect uphill line).

r = Σ(x − x̄)(y − ȳ) ÷ √( Σ(x − x̄)² × Σ(y − ȳ)² )
t = r √(n − 2) ÷ √(1 − r²), with n − 2 degrees of freedom

The t statistic tests whether the true correlation is zero. The two-tailed p-value comes from the t distribution. Spearman's ρ is the same Pearson formula applied to the ranks of x and y (tied values share the average rank), so it measures any steadily rising or falling pattern, not just a straight line.

Worked example

Take x = 1, 2, 3, 4, 5 and y = 2, 4, 5, 4, 5 (filled in above). The means are x̄ = 3 and ȳ = 4.

  • Deviations of x: −2, −1, 0, 1, 2. Deviations of y: −2, 0, 1, 0, 1.
  • Σ(x − x̄)(y − ȳ) = 4 + 0 + 0 + 0 + 2 = 6. Σ(x − x̄)² = 10. Σ(y − ȳ)² = 6.
  • r = 6 ÷ √(10 × 6) = 6 ÷ 7.74597 = 0.774597, and r² = 0.6.
  • t = 0.774597 × √3 ÷ √0.4 = 2.12132 with 3 degrees of freedom, so p = 0.124.

The relationship looks strong, but with only 5 points it isn't statistically significant at the 5% level. Spearman's ρ for the same data is 0.738.

What correlation can't tell you

  • Correlation isn't causation. Two things can move together because a third thing drives both.
  • r only measures straight-line patterns. A perfect U-shaped curve can have r near 0. Plot your data first.
  • One outlier can swing r a long way. Spearman's ρ is less affected by outliers.
  • The p-value assumes the pairs are independent and, for Pearson, roughly normal. The Spearman p-value here uses the common t approximation, which is rough for fewer than about 10 pairs.

Sources

How we checked this

Before every update, this calculator is run in a real browser with these known answers, and it must match all of them:

  • x 1–5, y 2, 4, 5, 4, 5: r = 0.774597 ✓
  • Same data: t = 2.12132, p = 0.124027 ✓
  • Same data: Spearman ρ = 0.737865 (average ranks for ties) ✓
  • Six pairs: r = 0.529809, p = 0.279645 ✓
  • Edge: a perfect downhill line gives r = −1 ✓
  • Edge: lists of different lengths are rejected ✓
  • Edge: constant x has no correlation ✓

Last checked October 26, 2026. Spotted something wrong? The math is done in your browser with the formula shown on this page, so you can check any result by hand.

Add this calculator to your website (free)

Paste this code into any web page. The calculator works on your page, resizes itself, has no ads and no tracking cookies, and nothing your visitors type is sent anywhere. More about embedding.

Questions people ask

What is a good correlation coefficient?

It depends on the field. A common rule of thumb calls |r| below 0.2 very weak, 0.2–0.4 weak, 0.4–0.6 moderate, 0.6–0.8 strong and above 0.8 very strong. Always check the p-value and a scatter plot too.

What does r² mean?

r² is the share of the variation in y that a straight line through x accounts for. r = 0.774597 gives r² = 0.6, so the line accounts for 60% of the variation.

What's the difference between Pearson and Spearman correlation?

Pearson measures straight-line relationships using the actual values. Spearman uses ranks, so it catches any steadily increasing or decreasing pattern and is less sensitive to outliers.

How many data points do I need?

At least 3 for the calculation, but the test has little power with small samples. With 10 pairs, r must be about 0.632 or more to be significant at the 5% level (two-tailed).

How do I find the correlation in Excel?

Use =CORREL(x_range, y_range) or =PEARSON(x_range, y_range). Both give the same Pearson r as this calculator.

Related calculators