2015-04-17 227 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特徵值。