I have been searching for alternate measures to compute spearman rank correlation that incorporates some sort of weighting in the calculation. I came across this paper by David C. Blest on weighted spearman rank correlation where he mentions the following result -

$$\sum_{k=1}^{n}\sum_{i=1}^{k} (q_i - i) = \sum_{i=1}^{n}(n+1-i)(q_i - i) = 1/2\sum_{i=1}^{n}d_i^2$$

where, $ d_i = q_i - i, 1\leqslant q_i , i \leqslant n. $

$q_i$ (scheme-1) and $i$ (scheme-2, where $i$ is monotonically increasing ) are two schemes of ranking (no ties) a given set of $n$ elements . Therefore, the rank tuple of the $i^{th}$ element is given by $(q_i,i) $.

The relation $$\sum_{k=1}^{n}\sum_{i=1}^{k} (q_i - i) = \sum_{i=1}^{n}(n+1-i)(q_i - i)$$ is pretty straightforward to prove, but I can't prove how $$1/2\sum_{i=1}^{n}d_i^2$$ is equal to the other two. It would be great if somebody can help me work this out.

P.S Any other metric to compute weighted rank correlation is also welcome.

  • $\begingroup$ (1) There is no third equality, which makes it difficult to know what you are asking. (2) Please provide details of the ranking. In particular, are ties allowed? How is $q_i$ related to $i$? $\endgroup$
    – whuber
    Commented Jul 8, 2023 at 4:00
  • $\begingroup$ Thanks for suggestions. I have edited . $\endgroup$
    – Jor_El
    Commented Jul 8, 2023 at 6:02
  • $\begingroup$ Use $\sum i^p=\sum q_i^p$ for all $p$ (you need the cases $p=1,2$). $\endgroup$
    – whuber
    Commented Jul 8, 2023 at 11:07

1 Answer 1


\begin{eqnarray*} \sum_{i=1}^n (n+1-i)(q_i-i)&=&\sum_{i=1}^n (n+1-q_i+q_i-i)(q_i-i)\\ &=& \sum_{i=1}^n (q_i-i)^2+\sum_{i=1}^n (n+1-q_i)(q_i-i). \end{eqnarray*} Now using $\sum q_i^2=\sum i^2$ and therefore $\sum q_i(q_i-i)=-\sum i(q_i-i)$, you get $$ \sum_{i=1}^n (n+1-q_i)(q_i-i)=-\sum_{i=1}^n (n+1-i)(q_i-i), $$ and \begin{eqnarray*} 2\sum_{i=1}^n (n+1-i)(q_i-i)=\sum_{i=1}^n d_i^2. \end{eqnarray*}


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.