Correlation Coefficient Calculator

Enter the x values and the matching y values in the same order, and choose Pearson (linear) or Spearman (rank) correlation.

Separate numbers with commas, spaces or new lines.
One y for each x, in the same order.
Spearman replaces each value by its rank first, so it measures any monotonic relationship and is less affected by outliers.

Correlation coefficient

0.9783

r² (coefficient of determination)

0.957

Sample covariance

30.7955

Pairs used (n)

12

Interpretation

Pearson r = 0.9783: very strong positive linear relationship (covariance shown is of the values).

How it works

The Pearson correlation coefficient r measures how closely two variables follow a straight line together. It runs from −1 (a perfect line sloping down) through 0 (no linear relationship) to +1 (a perfect line sloping up). It is the covariance of x and y scaled by both standard deviations, so it does not depend on the units either variable is measured in.

r² is the share of the variation in y that a straight line on x accounts for; r = 0.8 means 64% of y's variance is explained. The sample covariance is the unscaled version: positive when x and y move together, negative when they move apart, in units of x-units times y-units.

Spearman's rank correlation ρ asks the same question about the ranks of the values instead of the values themselves. Replace each x by its rank among the x's, each y by its rank among the y's (tied values share the average of the ranks they occupy), and compute Pearson r on the ranks. It equals 1 for any relationship that always increases, straight or curved, and is much less sensitive to a single extreme point.

Correlation says two things vary together; it does not say one causes the other, and a correlation near 0 does not rule out a strong curved relationship.

Formula

r = Σ(x − x̄)(y − ȳ) ÷ √(Σ(x − x̄)² × Σ(y − ȳ)²)
sample covariance = Σ(x − x̄)(y − ȳ) ÷ (n − 1)
r² = r × r
Spearman ρ = Pearson r of rank(x) and rank(y), ties given the average rank

Example

Twelve students' hours of study (1, 2, 2, 3, 4, 4, 5, 6, 6, 7, 8, 9) and test scores (52, 55, 60, 58, 63, 70, 68, 74, 79, 80, 85, 91). The means are 4.75 hours and 69.5833 points; Σ(x − x̄)(y − ȳ) = 338.75, Σ(x − x̄)² = 70.25 and Σ(y − ȳ)² = 1,706.9167. So r = 338.75 ÷ √(70.25 × 1,706.9167) = 0.9783, r² = 0.9570 and the sample covariance is 338.75 ÷ 11 = 30.7955.

Ranking the same data (the tied 2s share rank 2.5, the 4s rank 5.5, the 6s rank 8.5) gives Spearman ρ = 0.9737.

Assumptions and limitations

  • The two lists must have the same number of values, matched by position, and at least three pairs are needed.
  • Pearson r measures linear association only and is pulled strongly by outliers; Spearman measures monotonic association and is more robust.
  • Pearson r² is only the share of variance explained by a straight line. In Spearman mode the r² and covariance shown are those of the ranks.
  • The descriptive labels (very weak to very strong) follow Evans (1996): |r| under 0.2, 0.4, 0.6, 0.8 and above. They are a convention, not a test of significance; no p-value is computed.
  • Correlation is not causation, and a correlation computed from a few points is very uncertain.

Frequently asked questions

When should I use Spearman instead of Pearson?

When the relationship is clearly curved but consistently rising or falling, when the data are ordinal rankings rather than measurements, or when one or two outliers would dominate Pearson r. If the scatter plot looks like a straight band, Pearson is the more informative of the two.

Why is my Spearman result different from the 6Σd²/(n(n² − 1)) formula?

That shortcut is exact only when there are no ties. This calculator gives tied values the average of the ranks they would occupy and computes Pearson r on those ranks, which is the correct definition when ties are present; without ties the two agree exactly.