求两个变量的协方差
Xbar = np.float(np.mean(X)) Ybar = np.float(np.mean(Y)) s = 0.0 for i in range(X.shape[1]): s = s + (X[0,i]-Xbar)*(Y[0,i]-Ybar) r = s/float(X.shape[1]-1)#这里出错了,协方差除以n-1,0.026047412160079993 #求两个变量的协方差 covxy = np.cov(X,Y)#计算的是协方差矩阵。0.02604741