def spearman_correlation(ranks1, ranks2):
 n = 0
 res = 0
 for (k, d) in _rank_dists(ranks1, ranks2):
  res += (d * d)
  n += 1
 try:
  return (1 - ((6 * res) / (n * ((n * n) - 1))))
 except ZeroDivisionError:
  return 0.0

def spearman_correlation ( ranks1 , ranks2 ) : n = 0 res = 0 for ( k , d ) in _rank_dists ( ranks1 , ranks2 ) : res += ( d * d ) n += 1 try : return ( 1 - ( ( 6 * res ) / ( n * ( ( n * n ) - 1 ) ) ) ) except ZeroDivisionError : return 0.0
returns the spearman correlation coefficient for two rankings .