We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
n=int(input())#m = p = c = [];m=[];p=[];c=[];foriinrange(n):l=[int(x)forxininput().split()];m.append(l[0]);p.append(l[1]);c.append(l[2]);mm=sum(xforxinm)/n;mp=sum(xforxinp)/n;mc=sum(xforxinc)/n;sdm=int(sum((x-mm)**2forxinm)/(n-1));sdm=sdm**(1/2);sdp=int(sum((x-mp)**2forxinp)/(n-1));sdp=sdp**(1/2);sdc=int(sum((x-mc)**2forxinc)/(n-1));sdc=sdc**(1/2);_mp=sum(x*yfor(x,y)inzip(m,p));_pc=sum(x*yfor(x,y)inzip(p,c));_cm=sum(x*yfor(x,y)inzip(m,c));cor_mp=(_mp-n*mm*mp)/((n-1)*sdm*sdp);cor_pc=(_pc-n*mc*mp)/((n-1)*sdc*sdp);cor_cm=(_cm-n*mm*mc)/((n-1)*sdm*sdc);print(round(cor_mp,2),round(cor_pc,2),round(cor_cm,2),sep='\n')
Cookie support is required to access HackerRank
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 →
Why I am getting second output wrong.