two methods for calculating covariance