Comment by infocollector

4 years ago

Am I reading the paper definition correctly? If yes, why does the vertical line and horizontal line in 2D have so different correlations?

  def corr(x,y):
    n = len(x)
    an_array = np.stack((x, y), axis=-1)
    sorted_array = an_array[np.argsort(an_array[:, 0])]
    r = rankdata(sorted_array[:,1])
    s = sum(np.abs(np.diff(r)))
    return 1.0 - (3.0 \* s/(n\*n -1.0))

You're using the formula for the case where there are no ties, but the vertical line has all X values tied and the horizontal line has all Y values tied. Also, the case where Y is a constant is explicitly excluded from consideration in the paper.