LinearAlgebraError: SVD did not converge
Fernando Pérez
fperez528 at yahoo.com
Tue Aug 27 18:59:13 CEST 2002
Damian Menscher wrote:
> I'm trying to get the SVD inverse of a matrix, so I'm calling
> LinearAlgebra.generalized_inverse(M, rcond). But sometimes it
> bombs out with the error "LinearAlgebraError: SVD did not
> converge". Seems odd that it would die, considering Numerical
> Recipes states "SVD... (theoretically) cannot fail...." (section
> 15.4).
Keep in mind they're talking about it not failing to solve a least-squares
problem, not not failing in general for an arbitrary inversion problem. The
SVD decomposition always exists, but that doesn't mean that the inverse does.
What SVD buys you is the clear identification of the redundant directions, and
with this information you can (in the context of least squares fitting) make
an informed decision on what to do with them rather than trying to get a
delicate cancellation of arbitrarily large constants in the original problem.
In your case, you should try to identify where the problem is by computing the
SVD decomposition of your matrix first on its own, and looking at the
singular value spectrum. What's the largest to smallest ratio? That's the
condition number of your matrix, and a large one will be an indication that
your matrix is nearly singular (numerically), hence hell to invert. If that's
the case, you'll need to think a bit about your problem, since chances are a
black box inverter will always fail with a near-singular matrix.
cheers,
f.
More information about the Python-list
mailing list