fixed computation of sample covariance