0
votes

Consider singular value decomposition M=USV*. Then the eigenvalue decomposition of M* M gives M* M= V (S* S) V*=VS* U* USV*. I wish to verify this equality with numpy by showing that the eigenvectors returned by eigh function are the same as those returned by svd function:

# svd
U1,S1,V1=np.linalg.svd(M) 
S1=np.square(S1)
V1=V1.T

# eig
S2,V2=np.linalg.eigh(np.dot(M.T,M))
indx=np.argsort(S2)[::-1]
S2=S2[indx]
V2=V2[:,indx]

When I execute this code the vectors differ just by a sign. Example :-

v1 = array([[-0.33872745,  0.94088454],
   [-0.94088454, -0.33872745]])

and for v2:
v2 = array([[ 0.33872745, -0.94088454],
   [ 0.94088454,  0.33872745]])

Why is this difference occurring in Eigen Vector and how can it be solved ? Any help is appreciated thank you in advance !!

1

1 Answers

0
votes

The eigenvectors are unique up to a sign change (see https://math.stackexchange.com/questions/235396/eigenvalues-are-unique).

The up-to-the-sign uniqueness is since $$ A u = \lambda $$ also holds for $$ A (-u) = \lambda) (-u) $$.