Rank correlation done correctly, next to the formula that is usually wrong.
Rank correlation, and the formula that breaks
Nine tied values in each column. The shortcut says 0.8212 and the truth is 0.8133.
n = 10, t = 3.9534 on 8 degrees of freedom
ρ = 0.813291
The 6Σd² shortcut gives 0.821212 — it is exact only without ties, and this data has 18 tied values.
ρ (correct)
0.813291
Pearson on the midranks
ρ (6Σd² shortcut)
0.821212
wrong here
Gap
0.007921
caused by ties
Σd²
29.5000
what the shortcut uses
Pearson r
0.782432
on the raw values
Kendall τ-b
0.692308
the other rank measure
Two-tailed p
0.004216
t on 8 df
Tied values
9 + 9
in x and in y
Spearman is the ordinary correlation of these ranks, which is why the plot is of ranks rather than of the raw values. Points on the dashed line are pairs whose two ranks agree exactly.
The shortcut gives 0.821212 and the correct value is 0.813291 — a gap of 0.007921. 1 − 6Σd²/(n(n² − 1)) is derived by assuming the ranks are a permutation of 1 to n, so their variance is known in closed form. Tied values get midranks, the variance changes, and the derivation no longer holds. The correct value is always Pearson’s correlation of the midranks — which is what Spearman’s rho is, with the shortcut being a special case rather than the definition. Textbooks teach the special case and rarely mention the condition.
Pearson gives 0.782432 on the same data and Spearman gives 0.813291. They measure different things. Pearson asks how close the relationship is to a straight line; Spearman asks only whether it is monotone, so a perfect curve scores 1 on Spearman and less on Pearson. Spearman is also far less moved by an extreme value, because ranking caps how far any single point can be from the rest. Neither is the “robust version” of the other — they answer different questions, and the Pearson page covers the linear one.
Kendall’s τ-b on this data is 0.692308, against Spearman’s 0.813291. Both are rank correlations and they are not on the same scale: ρ runs about 1.5 times τ for moderately correlated data, so a ρ of 0.6 and a τ of 0.4 describe the same relationship. τ has the more direct reading — it is the probability that a random pair is ordered the same way in both variables, minus the probability that it is not — which the Kendall page covers.
What this tool shows
1 − 6Σd²/(n(n² − 1)) is exact only when nothing ties. The derivation assumes the ranks are a permutation of 1 to n. With ties the correct value is Pearson’s correlation of the midranks, and the shortcut drifts — by 0.0079 on the ordinal preset here. Both are printed, with the gap and the tie count that caused it.
ρ computed correctly, as Pearson’s correlation of the midranks
The 6Σd² shortcut beside it, with the gap and the number of ties
Pearson on the raw values, for the comparison that is usually the real question
Kendall’s τ-b, since the two rank measures are not on the same scale
A t test for ρ = 0 on n − 2 degrees of freedom
The rank scatter plot, which is what Spearman actually correlates
Both formulas Ties break one Midranks shown Against Pearson
0.8212 from the textbook formula, 0.8133 from the definition.
Updated 12 September 2026 · Works in any browser, no installation
Spearman’s rho is Pearson’s correlation applied to ranks. That is the definition, not a description of it — so it measures whether the relationship is monotone rather than whether it is linear, and an extreme value can move it only as far as one rank position. The Pearson calculator covers the linear question.
At a glance
Formula shown
Replace each value by its rank, with tied values sharing the average of the ranks they span, then compute Pearson’s correlation of the two rank columns. When no two values tie, that reduces algebraically to 1 − 6Σd²/(n(n² − 1)) where d is the per-pair rank difference. When values do tie, it does not, and only the first definition is correct.
Scenario support
Ordinal data such as Likert responses and rankings, relationships that are monotone but curved, data with outliers that would dominate Pearson, and any pair of variables where the ordering is meaningful but the spacing between values is not.
Educational estimate
Planning support from the values you enter — not professional advice.
Why ties break the formula you were taught
The shortcut is elegant and it is derived, not stipulated. Understanding the derivation is what tells you when it stops applying.
It assumes the ranks are exactly 1 to n. Under that assumption the mean and variance of the ranks are known in closed form, the Pearson formula collapses, and everything except Σd² cancels out. That is where 6/(n(n² − 1)) comes from.
Ties break the assumption. Tied values share a midrank, so the rank column is no longer a permutation of 1 to n. Its variance falls, the cancellation no longer happens, and the formula is computing something that is not Spearman’s rho.
The error is systematic, not random. Reducing the rank variance while the formula still assumes the full value makes the shortcut typically overstate the correlation. On the ordinal preset it says 0.8212 where the truth is 0.8133.
And ties are the normal case. Likert scales, ratings out of five, rounded measurements, small integer counts — exactly the data a rank correlation is chosen for. A formula that fails on ties fails on most of its own use cases.
A tie correction exists, and using the definition is simpler. You can patch Σd² with correction terms for each group of ties, or you can compute Pearson on the midranks and be done. This tool does the second and shows the first so the gap is visible.
Against Pearson: monotone, not linear
Spearman is often introduced as the non-parametric version of Pearson, which suggests it is the same measure made safer. It measures something different.
Pearson asks how close the points are to a straight line. Spearman asks only whether y tends to rise as x rises, at any rate and by any shape.
So a perfect curve scores differently. On y = x² over seven points Spearman is exactly 1 — the ordering is perfect — and Pearson is 0.9774, because a parabola is not a line. Neither number is wrong.
Outliers move them very differently. Ranking caps how far any one point can sit from the rest, so a wild value changes Spearman by at most a rank position and can change Pearson arbitrarily. The outlier preset shows both moving.
Spearman does not require normality, and Pearson does not either. Pearson’s coefficient is a descriptive statistic for any data; it is the significance test on it that assumes bivariate normality. Conflating the two is why Spearman gets recommended for the wrong reason.
Choose by what the numbers mean. If the spacing between values is meaningful — degrees, pounds, pounds sterling — Pearson uses information Spearman throws away. If only the order is meaningful, as with a 1-to-5 rating, Pearson is inventing a claim that the gap between 4 and 5 equals the gap between 1 and 2.
Against Kendall: the same question, a different scale
Both are rank correlations, both run from −1 to 1, and they are routinely compared as if a 0.6 in one meant the same as a 0.6 in the other. It does not.
ρ runs roughly 1.5 times τ for moderate correlations. So a Spearman of 0.6 and a Kendall of 0.4 usually describe the same relationship, and reporting one as “stronger” than the other is a unit error.
τ has the more direct meaning. It is the probability that a random pair of observations is ordered the same way in both variables, minus the probability that it is not. ρ is a correlation coefficient of ranks, which has no comparably clean reading.
ρ is more familiar and more powerful under normality. It is what most software reports by default and what most readers expect, and for bivariate normal data it has slightly more power.
τ handles ties more transparently. Its three variants — τ-a, τ-b and τ-c — make the tie handling an explicit choice rather than a hidden correction, which the Kendall page covers.
They rarely disagree about the conclusion. Both will say the relationship is strong, weak or absent. The disagreement is about the number, which matters only when a number is being compared against a threshold or against another study.
Testing ρ, and what the test assumes
The tool reports a t statistic on n − 2 degrees of freedom, which is the standard test and is an approximation rather than an exact result.
t = ρ√((n − 2)/(1 − ρ²)), the same expression used for Pearson. Under the null of no association the ranks are a random permutation, and that statistic is approximately t distributed.
At small n the approximation is poor, and exact tables based on enumerating permutations exist for n below about 10. With n = 5 there are only 120 possible rank orderings, so the p-value is coarse and a continuous approximation to it is optimistic.
Ties make it worse. The null distribution of rho depends on the tie pattern, which the t approximation ignores entirely. With heavy ties a permutation test on your actual data is the honest route.
The null is “independent”, not “ρ = 0”. A permutation test rejects when the variables are associated in any way that affects the ranks, which is a broader alternative than a zero correlation — and is usually what was wanted.
Report the coefficient, not just the p-value. With n = 200 a ρ of 0.15 is significant and describes almost nothing. Significance says the association is detectable; the coefficient says whether it matters.
What a rank correlation cannot tell you
Spearman is robust in a specific sense and not in a general one, and the distinction matters for what you can conclude.
It cannot see a non-monotone relationship. Data that rises then falls has a rho near zero, exactly as Pearson does. Ranking does not rescue a U-shape — only plotting it does, and the quadratic fit is what quantifies it.
It discards the magnitudes entirely. Two datasets with identical orderings have identical rhos however far apart their values are. That is the point, and it means rho cannot support a statement about how much y changes with x — only about whether it rises.
It says nothing about cause. Same caveat as any correlation, and worth repeating because a rank correlation on ordinal data often arrives in a context where a causal claim is being drafted.
It is not a substitute for looking at the data. Anscombe’s quartet works for rank correlations too: very different datasets can share a rho. The residual calculator carries the four datasets that make the point for the linear case.
And a coefficient on a subgroup can reverse on the whole. Rank correlations are as exposed to Simpson’s paradox as any other summary, because aggregating changes the ordering.
Report n alongside it. A rho of 0.8 on six points is one arrangement out of 720; on sixty it is a finding. The coefficient alone does not distinguish them.
Why it exists at all
Spearman published it in 1904, and the reason he needed it explains what the coefficient is for.
He was measuring general intelligence. School rankings, teachers’ judgements of cleverness, ratings of musical ability — data that had an order and no meaningful scale, which Pearson’s coefficient had been built for and did not fit.
Ranking made incomparable measures comparable. A teacher’s rating out of ten and a mathematics mark out of a hundred cannot be correlated directly in any defensible way. Their ranks can.
The 6Σd² form was a computational convenience. It reduces a correlation to a sum of squared integers, which mattered enormously when the alternative was hours of longhand arithmetic. It survives in teaching for a reason that no longer applies.
The factor 100 story is worth knowing. Spearman’s own correction for attenuation — dividing an observed correlation by the square root of the product of the two reliabilities — can push an estimate above 1, which is how a correlation coefficient ends up reported as impossible. The correction is still used and still does this.
Rank methods spread from here. Kendall’s tau, the Mann-Whitney test, the Kruskal-Wallis test and Wilcoxon’s all rest on the same move: replace the values with their order and the distributional assumptions largely go away.
Sources and methodology
References for the coefficient and its tie problem.
Method. ρ is computed as Pearson’s correlation of the midranks, which is the definition; the 6Σd²/(n(n² − 1)) shortcut is computed alongside and the gap is reported, because the shortcut is exact only when no two values tie and is taught almost everywhere without that condition. Midranks give tied values the average of the positions they span. The suite asserts that the two agree to machine precision on every untied dataset it generates and differ on essentially every tied one, that ρ equals Pearson on the midranks across 500 randomly tied datasets, that a perfect quadratic gives exactly 1 where Pearson does not, and that every rank correlation stays inside [−1, 1]. That engine is verified on every change against 67 assertions. The count and the per-case breakdown are published on the formula verification page.
Related calculators
Where this goes next:
Correlation CoefficientReports Pearson, Spearman and Kendall together with the scatter plot, and ships Anscombe's quartet built in — four datasets with an identical r of 0.816 that Spearman tells apart.
Kendall TauComputes τ-a, τ-b and τ-c with the concordant and discordant pair counts, because the three definitions disagree — 0.7143, 0.8729 and 0.9375 on the built-in tied preset, from the same eight pairs.
CovarianceSample and population covariance with a unit multiplier that shows why the magnitude is unreadable — rescaling x multiplies the covariance while leaving the correlation untouched.
Coefficient of DeterminationR-squared across five models at once with adjusted R-squared beside it, because adding a term can never lower it and the value most tools report for a curve fit was computed in log space.
Mann-Whitney UMann-Whitney U with the tie correction and both medians shown, because it is not a test of medians — two samples with identical medians of 4 are separated at p = 0.01.
ResidualResiduals, standardised and studentised residuals, leverage and Cook's distance, with Anscombe's quartet built in — including the dataset every residual rule scores cleanest and which one point controls entirely.
An educational tool. The t approximation for testing ρ is unreliable at small n and ignores the tie pattern entirely; with few observations or heavy ties an exact permutation test is the appropriate alternative.
Published a Spearman calculator that computes rho BOTH ways, because the formula everyone is taught — 1 − 6*sum(d^2)/(n(n^2−1)) — is exact only when no two values tie. The derivation assumes the ranks are a permutation of 1 to n so their variance is known in closed form; tied values get midranks, the variance changes, and the shortcut drifts. On the ordinal-ratings preset it says 0.8212 where the truth is 0.8133.
The correct value is always Pearson's correlation of the midranks, which is what Spearman's rho IS — the shortcut being a special case rather than the definition. Verified across 500 randomly tied datasets, and verified to be exact on every untied one the suite generates.
Shows Pearson on the raw values alongside, because the gap between them is itself informative: on a perfect quadratic rho is exactly 1 and Pearson is 0.9774, since rank correlation measures monotone rather than linear. Kendall's tau-b is shown too, with the warning that rho runs about 1.5 times tau so the two are not comparable.
Plots the midranks rather than the raw values, because that is what Spearman actually correlates, and states that the t approximation for testing rho is unreliable at small n and ignores the tie pattern entirely.
Add this calculator to your site
Responsive embed — and private: nothing your visitors type leaves their browser.