Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong reconstruction of covariance matrix after eigenvalue decomposition #15

Open
FuZhiyu opened this issue Jul 1, 2022 · 0 comments
Open

Comments

@FuZhiyu
Copy link

FuZhiyu commented Jul 1, 2022

In utils.jl, there is a mistake in the formula below when it reconstructs the covariance matrix after eigen decomposition:

return Symmetric(eigvect' * Diagonal(eigval) * eigvect)

The correct order should be:

eigvect * Diagonal(eigval) * eigvect'

i.e., the first matrix is not transposed while the last is. To quickly check,

using LinearAlgebra;
A = Symmetric(rand(3,3));
eigval, eigvect = eigen(A);
norm(eigvect * Diagonal(eigval) * eigvect' - A) < 1e-12  # true
norm(eigvect' * Diagonal(eigval) * eigvect - A) < 1e-12  # false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant