Verifying Covariance Eigendecomposition with Matrix Reconstruction
Summary
This article explains how to check a covariance matrix eigendecomposition using the spectral theorem. For a real symmetric covariance matrix, multiplying the eigenvector matrix by the diagonal eigenvalue matrix and the transpose of the eigenvector matrix should reproduce the original matrix. In exact arithmetic the reconstruction is exact; in numerical computation a small residual is expected from floating-point rounding.
The MQL5 example builds the diagonal matrix, performs the matrix multiplications, subtracts the reconstructed result from the original covariance matrix, and measures the residual with the Frobenius norm. It reports a maximum error and norm of 2.54×10⁻²¹ in its run, which the article interprets as rounding error. This validates the implementation for that dataset and run, rather than proving every eigensolver use is correct. The article also notes that variance shares change across market windows and introduces diagonalization, transposition, and matrix multiplication operations.
Key ideas
- A symmetric covariance matrix can be represented as the product of its eigenvectors, eigenvalues, and transposed eigenvectors.
- Reconstructing the matrix and measuring the residual provides a numerical check of an eigendecomposition.
- The example uses the Frobenius norm to summarize reconstruction error across all matrix entries.
- Reported residuals apply to the example run, while covariance structure can change as the data window moves.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.