fix some formulas
compute covariance matrix more efficient