I am trying to calculate the singular value decomposition of this matrix using
However, reconstructing the matrix from the SVD gives a poor reconstruction - in particular, the first row and second column are far smaller in the reconstruction than in the original matrix.
u, w, vt = np.linalg.svd(M) np.allclose(M, np.dot(u, np.dot(np.diag(w), vt))) >> False
The matrix is singular (
w[-1] is zero), and the largest singular value is much bigger than the other non-zero values (
7e-2 for the next largest).
Should I expect that the reconstruction from the SVD be poor for a matrix this badly conditioned? Are their other more stable ways I could calculate the SVD otherwise?
The reason I am computing the SVD is a diagnosis for the pseudoinverse of
M I calculate using
numpy.linalg.pinv, which should return the Moore-Penrose pseudoinverse. As I understand it, this particular pseudoinverse should be symmetric since
M is symmetric, but it is not. My assumption is that this is because of problems with the SVD, which