You are viewing a single comment's thread. Return to all comments →
Python sol
n = int(input()) X = list(map(float, input().split())) Y = list(map(float, input().split())) def getRanks(lst): arr = sorted(lst) ranks = {val:i+1 for i, val in enumerate(arr)} return [ranks[val] for val in lst] Rx = getRanks(X) Ry = getRanks(Y) SRCC = 1 - (6*sum([(rx-ry)**2 for rx,ry in zip(Rx, Ry)]))/(n*(n**2-1)) print(round(SRCC, 3))
Seems like cookies are disabled on this browser, please enable them to open this website
Day 7: Spearman's Rank Correlation Coefficient
You are viewing a single comment's thread. Return to all comments →
Python sol