@wikipedia


\rho_s(x,y) = \rho_p(rg(x),rg(y)) = 1 - \frac{6}{n(n^2-1)} \sum_i \big( rg(x_i)-rg(y_i) \big)^2

where  and  are the ranks of elements  and .