You are viewing a single comment's thread. Return to all comments →
Directly from definition:
em,ep,ec = 0.0,0.0,0.0 em2,ep2,ec2 = 0.0,0.0,0.0 emp,emc,epc = 0.0,0.0,0.0 n = int(input()) for _ in range(n): m,p,c = map(int,input().split()) em+=m ep+=p ec+=c em2+=m**2 ep2+=p**2 ec2+=c**2 emp+=m*p emc+=m*c epc+=p*c rmp=(n*emp-em*ep)/((n*em2-(em)**2)*(n*ep2-(ep)**2))**0.5 rpc=(n*epc-ec*ep)/((n*ec2-(ec)**2)*(n*ep2-(ep)**2))**0.5 rmc=(n*emc-em*ec)/((n*em2-(em)**2)*(n*ec2-(ec)**2))**0.5 print('%.2f\n%.2f\n%.2f' %(rmp,rpc,rmc))
exy actually means sum rather than expectation
Seems like cookies are disabled on this browser, please enable them to open this website
Day 5: Computing the Correlation
You are viewing a single comment's thread. Return to all comments →
Directly from definition:
exy actually means sum rather than expectation