You are viewing a single comment's thread. Return to all comments →
python sol
import math n = int(input()) x = list(map(float, input().split())) y = list(map(float, input().split())) lx = len(x) ly = len(y) meanX = sum(x)/lx meanY = sum(y)/ly sdX = math.sqrt(sum([math.pow(xi-meanX, 2) for xi in x])/lx) sdY = math.sqrt(sum([math.pow(yi-meanY, 2) for yi in y])/ly) PCC = (sum((xi-meanX)*(yi-meanY) for xi, yi in zip(x, y)))/(n*sdX*sdY) print(round(PCC, 3))
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 →
python sol