I’m working with some multi-dimensional float-valued data – I’ll call a single instance of this data . I have multiple samples , and want to compare these subspaces – namely, I want to compute the distance between pairs of subspaces.
Let’s assume that our subspaces are not rank-deficient – i.e. for a given subspace sample, all of our dimensions are linearly independent. Thus, the vectors form a basis set that spans some -d subspace in . We can think of each -d subspace as a hyperplane in -d space, just as we can think of a 2-d plane in 3-d space. One way to compare these subspaces is by using the “principle angles between subspaces” (or
angles between flats). We can compare the “angles” between these hyperplanes, which will tell us how “far apart” the two subspaces are.
where and are orthonormal bases such that that span the same subspace as the original columns of and , and and are lower triangular matrices. Next, we compute the matrix , and then apply the singular value decomposition:
We can sort of think of as the cross-covariance matrix. As such, the singular vectors represent the main orthogonal axes of cross-covariation between our two subspaces, while the singular values represent angles. In order to compute the principle angles of our subspaces, we simply take
which gives us the principle angles (in radians). Because the SVD is invariant to sign (+/-), the principle angles range between . This means that subspaces that span the same space have a principle angle of 0, and subspaces that are orthogonal (maximally far apart) to one another have a principle angle of .
In order to compute the “distance” between our subspaces, we can apply
various metrics to our vector of principle angles. The simplest approach is to apply the norm to our vector of principle angles, , as
This metric is called the
Grassmann Distance and is formally related to the geodesic distance between subspaces distributed on the Grassmannian manifold.
This, however, is a topic for another future blog post. There are a variety of metrics we can use to compute the pairwise distance between subspaces, some of which are
Asimov:
Fubini-Study:
Spectral:
but all are fundamentally based on some function of our vector of principle angles, .