Does scipy and numpy svd or eig always return the same singular / eigenvector?

Since the SVD decomposition is not unique (pairs of left and right singular vectors can be signed at the same time, I wonder to what extent the matrices U and V returned scipy.linalg.svd()

are "deterministic" / always the same?

I tried this several times with a random array on my machine and it seems to always return the same (luckily), but could this be different on different machines?

+3


source to share


1 answer


SciPy and Numpy compute SVDs using out-sourcing in LAPACK _gesdd

. Any deterministic implementation of this procedure will give the same results every time on a given machine with a given LAPACK implementation, but as far as I know, there is no guarantee that different LAPACK implementations (e.g. NETLIB vs MKL, OSX vs Windows, etc.) will use the same convention. If your application depends on some convention to resolve sign ambiguity, it would be safer to provide it yourself in some sort of post-processing of special vectors; one useful approach is given in the "Sign Ambiguity" section in Singular Value Decomposition (pdf)



+3


source







All Articles