A covariance matrix is a matrix that describes the variance and covariance of multiple variables.A covariance matrix is a square matrix that summarizes how multiple variables vary together. Each diagonal entry gives the variance of a single variable — how much it spreads around its mean — while each off-diagonal entry gives the covariance between two variables, indicating whether they tend to increase or decrease together. For a set of n variables, the matrix is n×n, and it is symmetric because the covariance between variable A and B is the same as between B and A.
The concept of covariance was formalized by Karl Pearson in the late 19th century, and the matrix form became standard in multivariate statistics during the 20th century.
To build the matrix, you compute the average of the product of deviations from the means for each pair of variables. If two variables move in the same direction, their covariance is positive; if opposite, negative; if unrelated, near zero. The matrix compactly encodes all pairwise relationships, and its eigenvalues and eigenvectors reveal the principal directions of variation in the data — the basis of principal component analysis.
It is used in machine learning for dimensionality reduction, in finance for portfolio risk assessment, and in physics for analyzing correlated measurements in experiments.
The covariance matrix of a multivariate normal distribution completely determines the shape and orientation of its probability cloud, from a sphere to a stretched ellipsoid.





