SubspaceDistance¶
Introduction¶
The SubspaceDistance class implements methods for measuring distances between linear subspaces spanned by matrices using Singular Value Decomposition (SVD). This measure is fundamental in various fields, including computer vision, signal processing, and data analysis, where comparing subspaces is essential for understanding data relationships and geometric structures.
Description¶
The subspace distance quantifies the geometric difference between two linear subspaces by analyzing their principal angles. These angles are computed efficiently using SVD, providing a robust and numerically stable way to measure how “far apart” two subspaces are from each other in terms of their spanning directions.
Mathematical Formulation¶
For two matrices A ∈ ℝ^(m×p) and B ∈ ℝ^(m×q), the subspace distance is computed using their orthonormal bases obtained through SVD:
The principal angles θᵢ between the subspaces are computed as:
where σᵢ are the singular values of U_A^T U_B.
The subspace distance can then be defined in several ways:
Geodesic distance: .. math:
d_{geo}(A,B) = \sqrt{\sum_{i=1}^{\min(p,q)} \theta_i^2}
Projection distance: .. math:
d_{proj}(A,B) = \sqrt{1 - \sigma_{min}^2(U_A^T U_B)}
Chordal distance: .. math:
d_{chord}(A,B) = \sqrt{\sum_{i=1}^{\min(p,q)} \sin^2(\theta_i)}
Properties¶
Non-negativity: d(A,B) ≥ 0
Identity of indiscernibles: d(A,B) = 0 iff span(A) = span(B)
Symmetry: d(A,B) = d(B,A)
Triangle inequality (for certain metrics)
Invariance under orthogonal transformations
Scale invariance
Implementation Features¶
The class provides: 1. Multiple distance metrics (geodesic, projection, chordal) 2. Efficient SVD computation 3. Handling of numerical instabilities 4. Support for sparse matrices 5. Dimension mismatch handling 6. Principal angles computation
Academic References¶
Golub, G. H., & Van Loan, C. F. (2013). Matrix Computations (4th ed.). Johns Hopkins University Press.
Björck, Å., & Golub, G. H. (1973). Numerical methods for computing angles between linear subspaces. Mathematics of Computation, 27(123), 579-594.
Absil, P.-A., Mahony, R., & Sepulchre, R. (2008). Optimization Algorithms on Matrix Manifolds. Princeton University Press.
Stewart, G. W., & Sun, J. G. (1990). Matrix Perturbation Theory. Academic Press.
Applications¶
Subspace distances are particularly useful in: - Computer vision (image set classification) - Signal processing (subspace tracking) - Pattern recognition (face recognition) - Data mining (subspace clustering) - Machine learning (domain adaptation) - Dimensionality reduction (manifold alignment)
Computational Considerations¶
SVD Computation: - Choice of SVD algorithm based on matrix size - Handling of rank-deficient matrices - Numerical stability in presence of small singular values
Efficiency: - Optimizations for high-dimensional data - Memory-efficient implementations - Parallel computation options
Conclusion¶
The SubspaceDistance class provides a comprehensive implementation of subspace distance metrics within the distancia package. Its robust implementation, based on SVD, ensures numerical stability and accuracy in comparing linear subspaces. The class supports multiple distance metrics and includes optimizations for various practical scenarios, making it suitable for both theoretical research and real-world applications.
Usage Notes¶
Input matrices should be preprocessed to handle numerical issues
Consider dimensionality and rank when choosing metrics
Be aware of computational complexity for large matrices
Use appropriate tolerance levels for numerical comparisons