2015-04-17 222 views
1

我读了约Singular Value Decomposition。引述维基百科:使用矩阵*(矩阵')的特征向量计算svd

The left-singular vectors of M are eigenvectors of MM∗. 
The right-singular vectors of M are eigenvectors of M∗M. 
The non-zero singular values of M (found on the diagonal entries of Σ) 
are the square roots of the non-zero eigenvalues of both M∗M and MM∗ 

我写这八度代码(控制台输出如下所示):

a是其SVD正在计算矩阵。

octave:1> a = [1,3;3,1] 
a = 

    1 3 
    3 1 

octave:3> [U,S,V] = svd(a) 
U = 

    -0.70711 -0.70711 
    -0.70711 0.70711 

S = 

Diagonal Matrix 

    4 0 
    0 2 

V = 

    -0.70711 0.70711 
    -0.70711 -0.70711 

检查SVD真的有用..

octave:4> U*S*V 
ans = 

    3.00000 -1.00000 
    1.00000 -3.00000 

octave:5> U*S*V' 
ans = 

    1.00000 3.00000 
    3.00000 1.00000 

现在先试的原则(维基百科)风格:

octave:6> b = a*a' 
b = 

    10 6 
    6 10 

octave:7> c = a'*a 
c = 

    10 6 
    6 10 

octave:8> [E1,L1] = eig(b) 
E1 = 

    -0.70711 0.70711 
    0.70711 0.70711 

L1 = 

Diagonal Matrix 

    4 0 
    0 16 

octave:9> [E2,L2] = eig(c) 
E2 = 

    -0.70711 0.70711 
    0.70711 0.70711 

L2 = 

Diagonal Matrix 

    4 0 
    0 16 

我可以看到的b和本征值c为正方形奇异值为a。这很酷。但left-singular-vectorsright-singular-vectors出错了......签名问题。

需要额外的步骤才能获得正确的值?

回答

0

你已经有了正确的值。

特征向量被定义为一个乘法常数。这从their definition明显可见。所以在你的情况下,[-0.70711; -0.70711][0.70711; 0.70711]是等效的。

并且在这两种情况下,[-1; 1]特征向量对应于sqrt(4)= 2特征值,而特征向量对应于sqrt(16)= 4特征值。