Ranking

Intermediate

What you need first. Nothing else on this path comes first. This page is part of Data analysis.

In data analysis, ranking is the replacement of each observation by its place in the ordered sample, with average places for ties. Ranking replaces each observation by its place in the ordered sample.

The smallest value receives rank 11, the next rank 22, and so on, unless a tie forces two or more values to share the places they jointly occupy. The average of those places is then the rank of each tied value. Spearman’s rank correlation, introduced in 1904, is the oldest widely used statistic that works entirely with those places.[1]

Ranking

Ranking
Fact Value
Topic Data analysis
Listed on Data analysis
Worked example 1

Motivating example

Four finishing times, in minutes, are 88, 33, 88, and 11. The clock readings carry the size of the gaps: the two 88s are five minutes behind the 33, and the 11 is only two minutes ahead of the 33. A rank summary throws the minutes away and keeps the order. The question it can still answer is who finished ahead of whom, including the fact that two runners finished together. It cannot answer how many minutes separated first from last.[1]

Definition

Order the sample from smallest to largest. If all nn values are distinct, the ranks are 1,2,…,n1, 2, \ldots, n in that order, written back against the original positions. If several observations have exactly the same value, each of them receives the average of the ranks those positions would have taken. For two values tied at the top of a list of four, the places 33 and 44 average to 3.53.5, and both tied values are ranked 3.53.5.

Spearman’s coefficient is the Pearson correlation of the two rank vectors, using average ranks (midranks) whenever values are tied. With gg tied groups in the first sample, of sizes tit_i, the centred sum of squares of its rank vector is

Sx=n(n2−1)−∑i=1g(ti3−ti)12,S_x=\frac{n(n^2-1)-\sum_{i=1}^{g}(t_i^3-t_i)}{12},

and likewise SyS_y for the second sample. Each is the sum of squared deviations of the ranks from their mean, (n+1)/2(n+1)/2. The same Pearson correlation can be expressed using SxS_x, SyS_y, and the sum of squared rank differences. The tie-group terms account for any ties, even a single tied pair. When there are no ties, each observation is a group of size 11, and t3−t=0t^3-t=0, so both centred sums of squares reduce to n(n2−1)/12n(n^2-1)/12.[1]

Properties

The ranks of nn observations, with average ranks for ties, still sum to n(n+1)/2n(n+1)/2, the sum of the first nn positive integers. Averaging the shared places is what keeps that identity. Giving every member of a tie the lowest place in the tie, or the highest, would change the sum.

For the times 88, 33, 88, and 11, the ordered values are 11, 33, 88, 88. The ranks in that order are 11, 22, 3.53.5, 3.53.5. Written against the original order they are 3.53.5, 22, 3.53.5, and 11, and

3.5+2+3.5+1=10=4⋅52.3.5+2+3.5+1=10=\frac{4\cdot 5}{2}.

The two 88s were five minutes from the 33 and seven minutes from the 11. Their ranks differ from the rank of 33 by 1.51.5 and from the rank of 11 by 2.52.5. The rank gaps are not proportional to the time gaps. That disproportion is the point of the replacement: the scale of the measurement has been discarded.[1]

A monotone transformation that does not change the order does not change the ranks. Replacing each time by its logarithm, or by any strictly increasing function, leaves 3.53.5, 22, 3.53.5, and 11 where they are. A transformation that is not monotone can change them.

Statistical use

Use ranks when the scientific comparison is about order, or when the raw scale is arbitrary but the order is not. Spearman’s coefficient then measures agreement between two rankings on a scale from −1-1 to +1+1. In the Reproducibility Project, original and replication effect sizes were positively associated, with Spearman’s r=0.51r=0.51.[2] A rank test of location compares the ranks in two or more groups rather than the raw measurements, which limits the influence of one wild value: that value receives the last place, and the size of its excess over the next value never enters the statistic.

The price is power against alternatives that live in the spacing.[1] If the groups differ by a shift on a scale that is already well measured, the raw measurements use that spacing and the ranks ignore it. Average ranks also need the tie correction in Spearman’s formula once ties are common. Ignoring the correction treats tied values as if they had been distinct.[1]

Worked example

The times 88, 33, 88, and 11 have ranks 3.53.5, 22, 3.53.5, and 11 in that order, and the ranks sum to 1010. The tied pair occupies places 33 and 44. Their average, 3.53.5, is the rank of each.

Your turn. Rank 44, 11, 44, and 99, using average ranks for the tie. Report the four ranks in the original order and their sum.

The ordered values are 11, 44, 44, 99. The ranks in that order are 11, 2.52.5, 2.52.5, and 44. In the original order they are 2.52.5, 11, 2.52.5, and 44, and they sum to 1010.

Common misconceptions

Rank 11 is the smallest value in the convention used here, not a judgement that the smallest value is the best. A race that scores the fastest time as first place is using the opposite orientation. The arithmetic of average ranks is the same after the orientation is reversed, but the number attached to a given runner is not.

A tie is not two observations with the same rank chosen arbitrarily. The average of the shared places is fixed by the places, not by a preference for the lower or the upper number. Assigning both of the tied 88s the rank 33, and nobody the rank 44, would make the ranks sum to 99 rather than 1010.

Spearman’s coefficient is not the Pearson correlation of the raw values. It is a correlation of the ranks. Two series can have a modest Pearson correlation and a Spearman correlation of 11 when one series is a strictly increasing curve of the other.[1]

Connections

Spearman’s rank correlation coefficient is the agreement measure built from two rankings. A rank transformation is a data reduction that keeps order and discards spacing. The median is the middle place of the ordered sample, so it is already a function of ranks. Methods that replace measurements by ranks in order to limit the pull of a wild value sit with robust statistics.[1]

Check yourself

Try these questions before opening an answer.

Why the ranks sum to the triangular number

Four distinct values are ranked 1 through 4, with no ties. What is the sum of the ranks, and why does a tie that is given average ranks keep the same sum?

The sum is 10, because the ranks are the first four positive integers. Average ranks share the places that those integers would have occupied, so the total is unchanged.

A tie for first

Two observations tie for the two best places when rank 1 is the smallest. Why is each given 1.5 rather than both given 1?

The places 1 and 2 are shared. Their average is 1.5. Giving both the rank 1 would drop the sum of all ranks below the sum for an untied ranking.

What the raw scale loses

Spearman’s coefficient is computed from ranks rather than from the raw measurements. What feature of the raw scale does that discard?

The spacing between the values. Only the order, and the average places of ties, remain. A strictly increasing transformation of the measurements leaves the ranks unchanged.

History

Spearman, a psychologist, introduced the rank correlation in 1904. Dodge calls it one of the oldest rank statistics. The average-rank rule for ties is part of the same definition: several observations with exactly the same value receive one shared rank, the average of the places they occupy, and the formula for the coefficient then corrects SxS_x and SyS_y by ∑(t3−t)\sum(t^3-t).[1]

See also

Line chart · Apriori algorithm · Asymptotic analysis · Average treatment effect · Base rate · Bayesian inference · Bayesian model · Bayesian probability

Glossary and index

References

  1. ^ a b c d e f g h i a. (p. 502) b. (p. 502) c. (p. 502) d. (p. 502) e. (p. 502) f. (p. 502) g. (p. 502) h. (p. 502) i. (p. 502) Dodge, Yadolah (2008). The Concise Encyclopedia of Statistics. Springer. https://doi.org/10.1007/978-0-387-32833-1
  2. ^ (Results) Open Science Collaboration (2015). Estimating the reproducibility of psychological science. Science, 349(6251). https://doi.org/10.1126/science.aac4716
Cite this page
Plain text
StatWiki (2026). "Ranking." StatWiki. Last updated 2 December 2026. https://www.statwiki.io/articles/ranking.html
BibTeX
@misc{statwiki_ranking,
  author = {{StatWiki}},
  title = {{Ranking}},
  year = {2026},
  url = {https://www.statwiki.io/articles/ranking.html},
  urldate = {2026-12-02},
  note = {StatWiki, last updated 2 December 2026}
}