# Measures of similarity or distance between two covariance matrices

Are there any measures of similarity or distance between two symmetric covariance matrices (both having the same dimensions)?

I am thinking here of analogues to KL divergence of two probability distributions or the Euclidean distance between vectors except applied to matrices. I imagine there would be quite a few similarity measurements.

Ideally I would also like to test the null hypothesis that two covariance matrices are identical.

You can use any of the norms $\| A-B \|_p$ (see Wikipedia on a variety of norms; note that the square-root of the sum of squared distances, $\sqrt{\sum_{i,j} (a_{ij}-b_{ij})^2}$, is called Frobenius norm, and is different from $L_2$ norm, which is the square root of the largest eigenvalue of $(A-B)^2$, although of course they would generate the same topology). The K-L distance between the two normal distributions with the same means (say zero) and the two specific covariance matrices is also available in Wikipedia as $\frac12 [ \mbox{tr} (A^{-1}B) - \mbox{ln}( |B|/|A| ) ]$.

Edit: if one of the matrices is a model-implied matrix, and the other is the sample covariance matrix, then of course you can form a likelihood ratio test between the two. My personal favorite collection of such tests for simple structures is given in Rencher (2002) Methods of Multivariate Analysis. More advanced cases are covered in covariance structure modeling, on which a reasonable starting point is Bollen (1989) Structural Equations with Latent Variables.

• i have a problem with $1/2(\verb+tr+(A^{-1}B)-\log(|B|/|A|))$: it doesn't give the same value if you permute $A$ and $B$ ( a real distance should be symmetric). – user603 Aug 23 '11 at 6:49
• i have a problem with $(A-B)^2$: it is not affine equivariant (if you rotate the matrices, there distance changes!). Furthermore, you should somehow scale your matrices (they might be measured in very different units), also, it is only natural to require that the distance between two covariance matrices be the same as the distance between the corresponding correlation matrices: so I suggest $(A\det(A)^{-1/p}-B\det(B)^{-1/p})^2$. – user603 Aug 23 '11 at 6:54
• First, K-L is not a real distance, and that's a well known fact. Second, if the matrices are measured in different units, they cannot be equal. – StasK Aug 23 '11 at 13:49
• Is K-L distance similar to likelihood ratio, or are they related? – hashmuke Dec 24 '16 at 15:48

A measure introduced by Herdin (2005) Correlation Matrix Distance, a Meaningful Measure for Evaluation of Non-Stationary MIMO Channels is $$d = 1 - \frac{\text{tr}(R_1 \cdot R_2)}{\|R_1\| \cdot \|R_2\|},$$ where the norm is the Frobenius norm.

• +1. Thanks a lot for this answer, it was very helpful to me. – amoeba Mar 2 '16 at 12:01
• This is one minus cosine similarity, right? – Firebug Aug 10 '16 at 13:33

Denote $\varSigma_1$ and $\varSigma_2$ your matrices both of dimension $p$.

1. Cond number: $\log(\lambda_1)-\log(\lambda_p)$ where $\lambda_1$ ($\lambda_p$) is the largest (smallest) eigenvalue of $\varSigma^*$, where $\varSigma^*$ is defined as: $\varSigma^*:=\varSigma_1^{-1/2}\varSigma_2\varSigma_1^{-1/2}$

Edit: I edited out the second of the two proposals. I think I had misunderstood the question. The proposal based on condition numbers is used in robust statistics a lot to assess quality of fit. An old source I could find for it is:

Yohai, V.J. and Maronna, R.A. (1990). The Maximum Bias of Robust Covariances. Communications in Statistics–Theory and Methods, 19, 3925–2933.

I had originally included the Det ratio measure:

1. Det ratio: $\log(\det(\varSigma^{**})/\sqrt{\det(\varSigma_2)*\det(\varSigma_1)})$ where $\varSigma^{**}=(\varSigma_1+\varSigma_2)/2$.

which would be the Bhattacharyya distance between two Gaussian distributions having the same location vector. I must have originally read the question as pertaining to a setting where the two covariances were coming from samples from populations assumed to have equal means.

The covariance matrix distance is used for tracking objects in Computer Vision.

The currently used metric is described in the article: "A metric for covariance matrices", by Förstner and Moonen.