logo

The Mean and Variance of Ranks in Statistics 📂Statistical Test

The Mean and Variance of Ranks in Statistics

Theorem 1

Let $n$ continuous random variables $X_{1} , \cdots , X_{n}$ be given as iid. Let the rank of each sample be $R \left( X_{1} \right) , \cdots , R \left( X_{n} \right)$. The probability distribution followed by the rank is the discrete uniform distribution $U (1, n)$, and the expectation and variance of $R$ are as follows. $$ \begin{align*} E \left( R \right) =& {\frac{ n + 1 }{ 2 }} \\ \Var \left( R \right) =& {\frac{ n^{2} - 1 }{ 12 }} \end{align*} $$

Proof

The rank as a function can be viewed as a permutation that maps the indices $k$ of $X_{k}$ to other natural numbers according to their order, and this is equivalent to selecting any natural number with equal probability. The probability mass function of $R$ is as follows. $$ p(r) = {\frac{ 1 }{ n }} \qquad , r = 1 , \cdots , n $$

Expectation

Formula for the sum of an arithmetic sequence: For an arithmetic sequence $a_{n} = a+(n-1)d$ with first term $a$ and common difference $d$ $$ \sum_{k=1}^{n} a_{k}= {{n \left\{ 2a + (n-1)d \right\} } \over {2}} $$

$$ \begin{align*} E \left( R \right) =& \sum_{r=1}^{n} r p(r) \\ =& {\frac{ n (n+1) }{ 2 }} {\frac{ 1 }{ n }} \\ =& {\frac{ n + 1 }{ 2 }} \end{align*} $$

Variance

Formula for the sum of squares: $$ \sum_{k=1}^{n} { k^2} = {{n(n+1)(2n+1)} \over {6}} $$

$$ \begin{align*} \Var \left( R \right) =& \sum_{r=1}^{n} \left( r - E \left( R \right) \right)^{2} p(r) \\ =& {\frac{ 1 }{ n }} \sum_{r=1}^{n} \left( r - {\frac{ n + 1 }{ 2 }} \right)^{2} \\ =& {\frac{ 1 }{ n }} \sum_{r=1}^{n} \left( r^{2} - (n+1) r + {\frac{ (n+1)^{2} }{ 4 }} \right) \\ =& {\frac{ 1 }{ n }} \left[ {\frac{ n (n+1) (2n+1) }{ 6 }} - (n+1) {\frac{ n (n+1) }{ 2 }} + n {\frac{ (n+1)^{2} }{ 4 }} \right] \\ =& {\frac{ n+1 }{ 12 }} \left[ 2 (2n + 1) - 6 (n+1) + 3 (n+1) \right] \\ =& {\frac{ n+1 }{ 12 }} \left( n - 1 \right) \end{align*} $$


  1. Kruskal, W. H., & Wallis, W. A. (1952). Use of Ranks in One-Criterion Variance Analysis. Journal of the American Statistical Association, 47(260), 583–621. https://doi.org/10.1080/01621459.1952.10483441 https://medstatistic.ru/articles/Kruskal%20and%20Wallis%201952.pdf 3.1. Two Samples ↩︎