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.
I am bit confused why its not mentioned to take the population standard deviation instead of the sample standarddeviation
# Enter your code here. Read input from STDIN. Print output to STDOUTimportmathimportstatisticsn=int(input())X=list(map(float,input().split()))Y=list(map(float,input().split()))defcalcpearsonCov(dataset1,dataset2):averagex=statistics.mean(dataset1)averagey=statistics.mean(dataset2)result=0foriinrange(0,len(dataset1)):result+=(dataset1[i]-averagex)*(dataset2[i]-averagey)#result = result *(1/len(dataset1))stdevx=statistics.pstdev(dataset1)stdevy=statistics.pstdev(dataset2)result=result/(n*(stdevx*stdevy))returnresultresult=calcpearsonCov(X,Y)print(round(result,3))
Cookie support is required to access HackerRank
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 →
I am bit confused why its not mentioned to take the population standard deviation instead of the sample standarddeviation