The covariance matrix is the generalization of the concept of variance to higher dimensions. Given a collection of vectors its covariance matrix is the matrix whose terms are given as

The two terms in the product are the deviation from the mean of all values of the -th element and the -th element of each respectively. It follows that the diagonal represents the plain old variance of .