LoginSignup
7
4

More than 5 years have passed since last update.

singular value decomposition(SVD)に関する確認

Posted at

objective

行列XのSVDがX*X'の固有値分解の結果と対応することを確認する。
このことは、SVDの結果を組み合わせると主成分分析と同等の結果を得られることの確認となる。
(計算上若干数値が変動する事はありえる)

sample code

下記を実行。3x4の整数行列AのSVDの結果と、
A*A', A'*Aの固有値分解の結果とで、
得られる直交行列が同じであることを確認する。
matlabで記述しました。

svdtest.m
A = randi(10, 3, 4);% generate a random integer matrix
[U, S, Vt] = svd(A)

[V1, D1] = eig(A*A')% eigen value decomposition of 3x3 matrix
[V2, D2] = eig(A'*A)% eigen value decomposition of 4x4 matrix

U*U'
Vt*Vt'

以下が実行結果。乱数なので変動します。

result
U =
    0.7254   -0.0404   -0.6872
    0.4703   -0.6999    0.5376
    0.5027    0.7131    0.4887
S =
   20.6317         0         0         0
         0    7.6724         0         0
         0         0    3.2354         0
Vt =
    0.6149    0.4172   -0.4172    0.5233
    0.5186    0.1506   -0.1283   -0.8318
    0.2041    0.4612    0.8600    0.0781
    0.5579   -0.7685    0.2644    0.1679
V1 = % 列ベクトルの並び順、正負が異なることもあるがSVDの結果のUと等しい
   -0.6872   -0.0404    0.7254
    0.5376   -0.6999    0.4703
    0.4887    0.7131    0.5027
D1 =
   10.4680         0         0
         0   58.8651         0
         0         0  425.6669
V2 = % 列ベクトルの並び順、正負が異なることもあるがSVDの結果のVtと等しい
   -0.5233    0.4172    0.4172    0.6149
    0.8318    0.1283    0.1506    0.5186
   -0.0781   -0.8600    0.4612    0.2041
   -0.1679   -0.2644   -0.7685    0.5579
D2 =
   -0.0000         0         0         0
         0   10.4680         0         0
         0         0   58.8651         0
         0         0         0  425.6669
U*U' = % SVDの結果のUとVtはもちろん直交行列
    1.0000         0         0
         0    1.0000   -0.0000
         0   -0.0000    1.0000
Vt*Vt' =
    1.0000   -0.0000   -0.0000    0.0000
   -0.0000    1.0000    0.0000   -0.0000
   -0.0000    0.0000    1.0000    0.0000
    0.0000   -0.0000    0.0000    1.0000

特異値Sについて, S*S'が実対称行列(A*A')の固有値と対応することも確認できます。

>> S*S'
ans =
  425.6669         0         0
         0   58.8651         0
         0         0   10.4680
% これがD2に等しいことが分かる。

線形代数の基礎ですが、こんな感じ。
SVDの結果がA*A'の固有値分解と同じであるので、
正方行列でない一般の行列を主成分分析しようと思ったら
NIPALSアルゴリズムの他にSVDを利用できる、ということになります。

7
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
4