You are viewing a single comment's thread. Return to all comments →
n = int(input()) a = list(map(float, input().split())) b = list(map(float, input().split())) mean = lambda x: sum(x)/len(x) std = lambda x: (sum([(i-mean(x))**2 for i in x])/len(x))**0.5 prsn = lambda n, a, b: sum((i[0]-mean(a))*(i[1]-mean(b)) for i in list(zip(a,b))) / (n*std(a)*std(b)) print(f'{prsn(n,a,b):.3f}')
Seems like cookies are disabled on this browser, please enable them to open this website
Day 7: Pearson Correlation Coefficient I
You are viewing a single comment's thread. Return to all comments →