Fix covariance calculation