from math import sqrt def multipl(a,b): sumofab=0.0 for i in range(len(a)): temp=a[i]*b[i] sumofab+=temp return sumofab def corrcoef(x,y): n=len(x) #求和 sum1=sum(x) sum2=sum(y) #求乘积之和 sumofxy=multipl(x,y) #求平方和 sumofx2 = sum([pow(i,2) for i in x]) sum…
template <class T1, class T2>double Pearson(std::vector<T1> &inst1, std::vector<T2> &inst2) { if(inst1.size() != inst2.size()) { std::cout<<"the size of the vectors is not the same\n"; return 0; } size_t n=inst1.s…