Skip to main content

DigitalCalculators.net

Correlation Calculator

Last updated By the DigitalCalculators.net team Free, no sign-up

Find Pearson’s correlation coefficient r or Spearman’s rank correlation from paired data, with r², the t statistic, the p-value, a confidence interval and a scatter plot. Ties are ranked correctly, and every step is shown.

Results

ItemValue

Steps

StepWorking
Correlation measures how closely two variables move together. It does not show that one causes the other. Pearson’s r measures a straight-line relationship and is sensitive to outliers. Spearman’s ρ is Pearson’s r worked out on the ranks, so it measures any relationship that keeps rising or keeps falling. The p-value uses t = r√((n − 2) ÷ (1 − r²)) with n − 2 degrees of freedom. The confidence interval for Pearson’s r uses the Fisher transformation and assumes roughly normal data.

Quick Answer

Pearson’s r = Σ(x − x̄)(y − ȳ) ÷ √(Σ(x − x̄)² × Σ(y − ȳ)²). It runs from −1 to 1. For the example hours of study and test scores, r = 0.9773, a strong positive correlation. With 10 pairs, t = 13.0329 on 8 degrees of freedom, so the two-tailed p-value is far below 0.05.

Last updated: 4 December 2026 ·How we calculate this: Pearson’s r and Spearman’s ρ

How This Correlation Calculator Works

Enter your X values in the first box and the matching Y values in the second, in the same order. Choose Pearson’s r for a straight-line relationship or Spearman’s ρ for a relationship that keeps rising or keeps falling, even if it curves. The calculator gives the coefficient, its square, the direction, a t test with its p-value and, for Pearson’s r, a confidence interval. It also draws a scatter plot that you can download, and shows the other coefficient so you can compare them.

Always look at the scatter plot. A single outlier, a curve or two separate groups can give a misleading r. If Pearson’s r and Spearman’s ρ are very different, the relationship may not be a straight line, or an outlier may be pulling r. To fit a line and make predictions, use our Linear Regression Calculator.

Quick explanation:

  • r = 1: the points lie on a rising straight line.
  • r = −1: the points lie on a falling straight line.
  • r near 0: no straight-line relationship, though there may be a curved one.
  • r²: the share of the variation in Y that a straight line on X accounts for.

How to Use the Correlation Calculator

  1. Enter the X values.
  2. Enter the matching Y values in the same order.
  3. Choose Pearson or Spearman, the test and the confidence level.
  4. Press Calculate or Enter.
  5. Read r, the p-value and the interval, look at the scatter plot, then save or share.

Core Formulas

  • Pearson’s r: Σ(x − x̄)(y − ȳ) ÷ √(Σ(x − x̄)² × Σ(y − ȳ)²)
  • Spearman’s ρ: Pearson’s r worked out on the ranks of X and the ranks of Y. Tied values get the average of the ranks they cover.
  • t statistic: t = r√((n − 2) ÷ (1 − r²)), with n − 2 degrees of freedom
  • Fisher transformation: z = artanh(r), with standard error 1 ÷ √(n − 3)
  • Confidence interval: tanh(artanh(r) ± z* ÷ √(n − 3)), where z* is 1.96 for 95%

Key Terms

  • Correlation coefficient: a number from −1 to 1 that shows how closely two variables move together.
  • r²: the coefficient of determination, the square of r.
  • Rank: a value’s position when the data are sorted.
  • Tie: two or more equal values, which share the average of their ranks.
  • Fisher transformation: artanh(r), used to build a confidence interval for r.

Worked Example

Ten students recorded hours of study (X: 1, 2, 2, 3, 4, 5, 6, 6, 7, 8) and test scores (Y: 52, 55, 61, 60, 66, 70, 71, 78, 80, 85).

  • The means are x̄ = 4.4 and ȳ = 67.8.
  • Pearson’s r = 0.9773, so r² = 0.9550. A straight line on hours accounts for about 96% of the variation in scores.
  • t = 0.9773 × √(8 ÷ (1 − 0.9773²)) = 13.0329, with 8 degrees of freedom. The two-tailed p-value is about 1.1 × 10⁻⁶.
  • The 95% confidence interval for the true correlation is 0.9036 to 0.9948.
  • Spearman’s ρ is 0.9756. Two students studied 2 hours and two studied 6, so those ties share average ranks of 2.5 and 7.5.

This is made-up data, and it shows only that the two go together in this group. It doesn’t prove that studying more caused the higher scores, though it’s consistent with that.

Real-Life Examples

  • Homework: find r and r² and show the working.
  • Science projects: check whether two measurements rise together.
  • Surveys: use Spearman’s ρ for ratings and rankings.
  • Business: see whether ad spending and sales move together.

Pearson vs Spearman

  • Pearson’s r: measures how close the points are to a straight line. Needs numbers on a measured scale and is sensitive to outliers.
  • Spearman’s ρ: measures whether Y keeps rising or keeps falling as X rises. Works for ranks and ratings, and outliers matter less.
  • Both: run from −1 to 1 and use the same t test.

Two-Tailed Critical Values of r

From r = t ÷ √(n − 2 + t²), using critical t values with n − 2 degrees of freedom. With more pairs, a smaller r is enough to be significant.

Pairs (n)α = 0.10α = 0.05α = 0.01
50.8050.8780.959
100.5490.6320.765
150.4410.5140.641
200.3780.4440.561
300.3060.3610.463
500.2350.2790.361
1000.1650.1970.256

Spearman’s Rank Correlation and Ties

Many textbooks give the shortcut ρ = 1 − 6Σd² ÷ (n(n² − 1)), where d is the difference between the two ranks. It only works when there are no ties. With ties, the correct method is to give tied values the average of their ranks and then work out Pearson’s r on the ranks, which is what this calculator does.

Wikipedia’s example uses IQ (106, 100, 86, 101, 99, 103, 97, 113, 112, 110) and hours of TV per week (7, 27, 2, 50, 28, 29, 20, 12, 6, 17). There are no ties, and both methods give ρ = −29/165 = −0.175758, with a two-tailed p-value of 0.627188 from the t distribution. Enter the data with Spearman’s ρ to check it.

Correlation Isn’t Causation

  • Hidden factors: a third variable can drive both X and Y.
  • Direction: even if one causes the other, correlation doesn’t say which way.
  • Restricted range: looking at only part of the data can weaken r.
  • Outliers: one extreme point can create or hide a correlation. Check with the Outlier Calculator.
  • Curves: a strong U-shaped relationship can have r close to 0.

Common Mistakes to Avoid

  • Mismatched pairs. The X and Y lists must be in the same order.
  • Assuming causation. Correlation alone can’t show it.
  • Skipping the scatter plot. Curves and outliers can mislead.
  • Using the 6Σd² shortcut with ties. It gives the wrong ρ.
  • Confusing significance with strength. With many pairs, even a weak r can be significant.

Frequently Asked Questions

Enter the X and Y values and press Calculate. By hand, r = Σ(x − x̄)(y − ȳ) ÷ √(Σ(x − x̄)² × Σ(y − ȳ)²).

How closely the points follow a straight line. Positive means they rise together, negative means one falls as the other rises.

There’s no single rule, and what counts as strong varies between fields. Look at r, the scatter plot and the p-value together.

The square of r. It’s the share of the variation in Y that a straight line on X accounts for.

For ranks or ratings, for relationships that curve but keep rising or falling, or when outliers are a concern.

Tied values get the average of the ranks they cover, then Pearson’s r is worked out on the ranks.

From t = r√((n − 2) ÷ (1 − r²)) with n − 2 degrees of freedom, using the exact t distribution.

No. A hidden factor, chance or reverse causation can explain it.

At least 3, and at least 4 for a confidence interval. Small samples give wide intervals.

The Fisher interval shown here is the standard one for Pearson’s r with roughly normal data, so it’s only shown for Pearson.

Yes, as a PNG image or an SVG file.

Yes. Paste the X column in the first box and the Y column in the second.

Yes. Save each set by name in this browser.

Yes. Use Compare: keep as A.

Yes. Use Share link or Print.

References & Sources

SourceUsed ForLink
Wikipedia, Pearson correlation coefficient The formula for r, the t test with n − 2 degrees of freedom, and the Fisher transformation interval. https://en.wikipedia.org/wiki/Pearson_correlation_coefficient
Wikipedia, Spearman’s rank correlation coefficient Pearson’s r on ranks, average ranks for ties, why the 6Σd² shortcut fails with ties, and the worked example. https://en.wikipedia.org/wiki/Spearman%27s_rank_correlation_coefficient
Python documentation, statistics Used to check this calculator’s results: quantiles, correlation and ranked correlation. https://docs.python.org/3/library/statistics.html

Cite or share this calculator

DigitalCalculators.net. (2026, December 4). Correlation Calculator. https://digitalcalculators.net/correlation-calculator/