Distance/Similarity between two matrices

I’m in the process of writing an application which identifies the closest matrix from a set of square matrices M to a given square matrix A. The closest can be defined as the most similar.

I think finding the distance between two given matrices is a fair approach since the smallest Euclidean distance is used to identify the closeness of vectors.

I found that the distance between two matrices (A,B) could be calculated using the Frobenius distance F:

FA,B=trace((AB)(AB))

where B represents the conjugate transpose of B.

I have the following points I need to clarify

  • Is the distance between matrices a fair measure of similarity?
  • If distance is used, is Frobenius distance a fair measure for this problem? any other suggestions?

Answer

Some suggestions. Too long for a comment:

As I said, there are many ways to measure the “distance” between two matrices. If the matrices are A=(aij) and B=(bij), then some examples are:
d1(A,B)=ni=1nj=1|aijbij|
d2(A,B)=ni=1nj=1(aijbij)2
d(A,B)=max

d_m(\mathbf{A}, \mathbf{B}) = \max\{ \|(\mathbf{A} – \mathbf{B})\mathbf{x}\| : \mathbf{x} \in \mathbb{R}^n, \|\mathbf{x}\| = 1 \}

I’m sure there are many others. If you look up “matrix norms”, you’ll find lots of material. And if \|\;\| is any matrix norm, then \| \mathbf{A} – \mathbf{B}\| gives you a measure of the “distance” between two matrices \mathbf{A} and \mathbf{B}.

Or, you could simply count the number of positions where |a_{ij} – b_{ij}| is larger than some threshold number. This doesn’t have all the nice properties of a distance derived from a norm, but it still might be suitable for your needs.

These distance measures all have somewhat different properties. For example, the third one shown above will tell you that two matrices are far apart even if all their entries are the same except for a large difference in one position.

Attribution
Source : Link , Question Author : Synex , Answer Author : bubba

Leave a Comment