added a routine that geneartes the covariance matrix from raw data.