Why Ranks Ignore the Measurement Scale
A rank records relative position, not the numerical distance between observations. If a strictly increasing function changes the measurement scale, the observations remain in the same order, even if their values change substantially. A strictly decreasing function reverses the order. These simple facts let us compare samples without requiring a particular numerical scale or a specified continuous population distribution.
The key distinction is whether the same transformation is applied to every observation being compared. A common strictly monotone transformation preserves or reverses all pairwise comparisons consistently. Transforming the two samples differently, even with increasing functions, need not preserve comparisons between them.
Increasing Transformations Preserve Ranks
A function \(g\) is strictly increasing on a set \(D\) if \(a<b\) implies \(g(a)<g(b)\) for all \(a,b\in D\). When all the observations lie in \(D\), this property preserves every pairwise ordering.
Proof. For every \(j\), strict increase gives \(z_j<z_i\) if and only if \(g(z_j)<g(z_i)\). Consequently, the number of observations below \(z_i\) equals the number below \(g(z_i)\). Adding 1 to both counts gives the same rank. \(\square\)
Worked Example: Positive Affine Rescaling
Suppose the observations are \(2,5,9\), with corresponding labels \(A,B,C\). Their ascending ranks are \(1,2,3\). Convert every value using \(g(x)=3x+7\). Since \(3>0\), \(g\) is strictly increasing.
The transformed values are \(g(2)=13\), \(g(5)=22\), and \(g(9)=34\). They remain in the order \(13<22<34\), so the ranks of \(A,B,C\) are still \(1,2,3\). The change of units and origin affects values but not ranks.
The theorem applies to any strictly increasing function on the observations' domain, not just a linear rescaling. For instance, exponentiation preserves ranks on the real line, while squaring is not strictly increasing on the whole real line: it reverses the order of negative values relative to some positive values. A transformation must be monotone on the set where the observations lie.
Decreasing Transformations Reverse Ranks
A function \(g\) is strictly decreasing on \(D\) if \(a<b\) implies \(g(a)>g(b)\). It reverses every pairwise comparison. Thus the smallest original value becomes the largest transformed value.
Proof. Let \(R_i\) be the original rank of \(z_i\). There are \(R_i-1\) original observations below \(z_i\), and \(N-R_i\) above it. Strict decrease turns the \(N-R_i\) observations above \(z_i\) into values below \(g(z_i)\), and no others lie below \(g(z_i)\). Its transformed rank is therefore $$ 1+(N-R_i)=N+1-R_i. $$ This proves the result. \(\square\)
Worked Example: Reversing Ranks by Negation
Take the distinct observations \(-2,1,4,10\). Their ranks in the displayed order are \(1,2,3,4\). Negation, \(g(x)=-x\), is strictly decreasing.
The transformed observations are \(2,-1,-4,-10\). In ascending order they are \(-10,-4,-1,2\), corresponding to the original observations \(10,4,1,-2\). Therefore the original ranks \(1,2,3,4\) become \(4,3,2,1\), in agreement with \(N+1-R_i=5-R_i\).
This reversal also applies to pooled ranks: if \(N=n+m\) observations are ranked together, a common strictly decreasing transformation changes each pooled rank \(R\) to \(N+1-R\). It does not turn a decreasing transformation into rank preservation; instead, it gives a precise, deterministic reversal.
A Distribution-Free Two-Sample Comparison
Consider independent samples \(X_1,\ldots,X_n\) and \(Y_1,\ldots,Y_m\) from the same continuous distribution \(F\). Continuity ensures that ties have probability zero, so the pooled observations have distinct ranks with probability 1. Define the comparison count $$ U=\sum_{i=1}^{n}\sum_{j=1}^{m} I(X_i<Y_j), $$ where \(I(A)\) is 1 when the event \(A\) holds and 0 otherwise. Thus \(U\) counts the cross-sample pairs in which an \(X\)-observation is below a \(Y\)-observation; it can take values from 0 to \(nm\).
The null condition here is that both independent samples come from the same continuous distribution. Under this condition, every assignment of the \(n\) \(X\)-labels to \(n\) of the \(N=n+m\) pooled ranks is equally likely. The resulting law of \(U\) depends on \(n\) and \(m\), but not on \(F\).
Proof. The \(N\) observations are independent and identically distributed, so their joint law is unchanged by any permutation of their labels. With probability 1, each pooled ordering is strict. Permuting labels gives a one-to-one correspondence between any two specified assignments of \(X\)- and \(Y\)-labels to the ordered positions. By exchangeability, all such assignments have equal probability. There are \(\binom{N}{n}\) possible choices of the \(n\) positions occupied by \(X\)-labels, so each choice has probability \(1/\binom{N}{n}\). The value of \(U\) is determined entirely by the chosen positions, which proves that its distribution is independent of \(F\). \(\square\)
There is a useful formula for computing \(U\) from the sum \(R_X\) of the \(X\)-observations' pooled ranks. For each \(X_i\), \(R_i-1\) counts all pooled observations below it. Across all \(X_i\), the \(X\)-observations themselves contribute \(n(n-1)/2\) such counts: each pair of \(X\)-observations contributes once, for the higher-ranked member. The remaining counts are pairs with \(Y_j<X_i\). Since there are \(nm\) cross-sample pairs altogether and no ties, the number with \(X_i<Y_j\) is the complement of that count. Hence
The direction of the comparison matters: the rank-sum excess counts \(Y_j<X_i\), not \(X_i<Y_j\). Confusing these two counts replaces \(U\) by \(nm-U\).
Worked Example: Checking a Rank Sum Against Pair Counts
Let the pooled order from smallest to largest be \(X_1,Y_1,Y_2,X_2\). Here \(n=m=2\), and the \(X\)-ranks are 1 and 4, so \(R_X=5\). Directly counting cross-sample pairs, \(X_1\) is below both \(Y\)-observations and contributes 2; \(X_2\) is above both and contributes 0. Thus \(U=2\).
The rank-sum formula gives the same answer: $$ U=nm-\left(R_X-\frac{n(n+1)}{2}\right) =4-\left(5-\frac{2\cdot3}{2}\right) =4-(5-3)=2. $$ In contrast, \(R_X-3=2\) counts pairs with \(Y_j<X_i\) here; its numerical equality to \(U\) is particular to this allocation, not a reason to use it as the general formula.
Worked Example: Exact Null Law for Two Observations per Sample
Set \(n=m=2\). Under the common continuous distribution assumption, the \(X\)-ranks are equally likely to be any of the \(\binom{4}{2}=6\) two-element subsets of \(\{1,2,3,4\}\). For each allocation, count the \(Y\)-ranks above each \(X\)-rank to obtain \(U\):
- \(\{1,2\}\): the \(X\)-ranks contribute 2 and 2, so \(U=4\).
- \(\{1,3\}\): they contribute 2 and 1, so \(U=3\).
- \(\{1,4\}\): they contribute 2 and 0, so \(U=2\).
- \(\{2,3\}\): they contribute 1 and 1, so \(U=2\).
- \(\{2,4\}\): they contribute 1 and 0, so \(U=1\).
- \(\{3,4\}\): they contribute 0 and 0, so \(U=0\).
Each allocation has probability \(1/6\). Therefore \(P(U=0)=1/6\), \(P(U=1)=1/6\), \(P(U=2)=2/6\), \(P(U=3)=1/6\), and \(P(U=4)=1/6\). This finite calculation is exact for every common continuous \(F\), not just for a particular choice such as a normal distribution.
What Transformations Do to the Comparison Count
A common strictly increasing transformation preserves every inequality \(X_i<Y_j\), and therefore leaves \(U\) unchanged. A common strictly decreasing transformation turns each such inequality into \(g(X_i)>g(Y_j)\). With no ties, exactly one of \(g(X_i)<g(Y_j)\) and \(g(Y_j)<g(X_i)\) holds, so the transformed count of \(X\)-below-\(Y\) pairs is \(nm-U\).
Worked Example: A Decreasing Transformation Complements the Count
Suppose \(n=2\), \(m=2\), and the pooled ranks for the \(X\)-sample are \(\{1,3\}\). As counted above, \(U=3\): the rank-1 \(X\)-observation is below both \(Y\)-observations, while the rank-3 \(X\)-observation is below one of them. Apply the common transformation \(g(x)=-x\). It is strictly decreasing, so each of the four cross-sample pairwise comparisons reverses direction.
The transformed comparison count is \(nm-U=4-3=1\). Equivalently, the \(X\)-ranks become \(\{4,2\}\) among the reversed pooled order; the rank-4 observation contributes 0 and the rank-2 observation contributes 1. The result agrees with the complement calculation.
Why Distribution-Free Rank Comparisons Matter
When two independent samples share an unknown continuous distribution, their raw values may have an unfamiliar scale or shape. The exact rank-allocation argument still gives a null reference law for \(U\), without estimating that common distribution. This is the central reason rank comparisons are useful when a model for the numerical values is undesirable. The same rank information survives common increasing changes of scale, and the direction can be translated under a common decreasing change.
“Distribution-free” has specific assumptions here. The samples must be independent and identically distributed under the null, and continuity is used to rule out ties. It does not mean that every rank statistic has the same law in every setting, or that the result holds under unequal population distributions. If the two groups are transformed separately, cross-group ordering can also change even when each transformation is increasing.
Common Mistakes
- Using the rank-sum excess as \(U\) without checking its direction. The quantity \(R_X-n(n+1)/2\) counts pairs with \(Y_j<X_i\). The count of pairs with \(X_i<Y_j\) is \(nm\) minus that quantity.
- Assuming a decreasing transformation preserves ranks. It reverses them: ascending rank \(R\) becomes \(N+1-R\), and the two-sample count \(U\) becomes \(nm-U\).
- Applying different transformations to the two groups and assuming comparisons are unchanged. A pair \(X_i<Y_j\) need not remain ordered if its two observations are transformed by different functions.
- Calling the rank law distribution-free without stating conditions. The result above uses independent samples from the same continuous distribution. Ties require a separate treatment and are not covered by this argument.
Check Your Understanding
Use distinct observations unless a question explicitly says otherwise.
- A sample has ascending ranks \(1,2,3,4,5\). What are the ranks after applying a common strictly decreasing transformation?
- Explain why applying the same strictly increasing function to both samples leaves \(U=\sum_{i=1}^{n}\sum_{j=1}^{m} I(X_i<Y_j)\) unchanged.
- For pooled ranks \(\{1,4\}\) belonging to \(X\), with \(n=m=2\), compute \(U\) directly and then verify it using the rank-sum formula.
- State the assumptions that make the pooled \(X\)-rank allocation uniform under the two-sample null.
- Why can a rank comparison change if the two groups are transformed using different strictly increasing functions?