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-vectors
和right-singular-vectors
出錯了......簽名問題。
需要額外的步驟才能獲得正確的值?