problem with svd in numpy
Robert Kern
robert.kern at gmail.com
Thu Nov 2 14:36:12 EST 2006
Zeynep Gerek wrote:
> Hello,
>
> I am having weird problem with svd routine in python.
numpy questions are best asked on the numpy list.
http://www.scipy.org/Mailing_Lists
> I am comparing
> eigenvector values from python and matlab. And they are giving different
> values. Actually, they are same but python gives negative values of
> these numbers.
>
> This is my test program (I am dealing with 100x100 matrices) with the
> array I used in matlab.
> I am not sure if svd in numpy has a problem or not. When I test this
> matrix in matlab, eigenvector values are different, Any idea why I am
> not getting exact results from both program?
You didn't show what code you executed in Matlab. Did you also do an SVD there,
or did you do an eigenvalue decomposition? The two are not the same thing. Which
did you intend to do?
In any case, it looks as if numpy_u == -matlab_u. How do numpy_vt and matlab_vt
compare? Do they also have flipped signs? If so, then there is no problem. (u,
vt) can be replaced with (-u, -vt). The SVD is not unique. Which one you get
depends on the precise operations of the implementation.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the Python-list
mailing list