Matrix Decomposition

2020-01-07
Jun Sok Huhh | ๐Ÿ lostineconomics.com

Summary in advance

Name AโˆˆA \in Restriction Comments
LU Rmร—n{\mathbb R}^{m \times n}
Cholesky Cnร—n{\mathbb C}^{n \times n} PD, Symmetric(Hermite) fast algorithm
Eigendecomposition Cnร—n{\mathbb C}^{n \times n} invertible
QR Rmร—n{\mathbb R}^{m \times n} Gram-Schmidt processing
SVD Cmร—n{\mathbb C}^{m \times n}

LU Decomposition

Row operation

Solution for linear equation

Ax=bA x = b์™€ ๊ฐ™์€ ์ ๋‹นํ•œ ์„ ํ˜• ์—ฐ๋ฆฝ๋ฐฉ์ •์‹์ด ์žˆ๋‹ค๊ณ  ํ•˜์ž. ์ด๋•Œ

PA=LU P A= LU

PAx=PbLUx=Pb \begin{aligned} P A x & = P b \\ LU x & = Pb \end{aligned}

์ด๋•Œ, Ux=yUx =y๋ผ๊ณ  ๋‘๊ณ  ๋ฌธ์ œ๋ฅผ ํ•œ๋ฒˆ ํ’€๊ณ , Ly=PbLy = Pb๋ผ๊ณ  ๋‘๊ณ  ๋ฌธ์ œ๋ฅผ ๋‹ค์‹œ ํ•œ๋ฒˆ ํ’€๋ฉด ํ•ด๋ฅผ ์‰ฝ๊ฒŒ ๊ตฌํ•  ์ˆ˜ ์žˆ๋‹ค.

Determinant

A=Pโˆ’1LUA = P^{-1} L U ๋ฅผ ๋งŒ์กฑํ•˜๊ณ ,

detโกA=detโกPโˆ’1detโกLdetโกU=detโกP(โˆi=1nlii)(โˆi=1nuii)=(โˆ’1)S(โˆi=1nlii)(โˆi=1nuii) \begin{aligned} \det A & = \det P^{-1} \det L \det U \\ & = \det P (\prod _{i=1}^{n} l_{ii}) (\prod _{i=1}^{n} u_{ii}) \\ & = (-1)^S (\prod _{i=1}^{n} l_{ii}) (\prod _{i=1}^{n} u_{ii}) \end{aligned}

Cholesky Decomposition

A=Aโˆ—, where Aij=Ajiโ€พ A = A^*,~\text{where}~A_{ij} = \overline{A_{ji}}

A=LLโˆ— A = L L^*

A=LLT A = L L^T

Eigendecomposition

QR decomposition

Gram-Schmidt processing

A=[โˆฃ โ€ฆ โˆฃv1 โ€ฆ vnโˆฃ โ€ฆ โˆฃ] A = \begin{bmatrix} \vert ~ & \dotsc & ~ \vert \\ v_1 ~ & \dotsc & ~ v_n \\ \vert ~ & \dotsc & ~ \vert \\ \end{bmatrix}

u1=v1, e1=u1โˆฅu1โˆฅu2=v2โˆ’(v2โ‹…e1)e1, e2=u2โˆฅu2โˆฅvk+1=vk+1โˆ’(vk+1โ‹…e1)e1โˆ’โ‹ฏโˆ’(vk+1โ‹…ek)ek, ek+1=uk+1โˆฅuk+1โˆฅ \begin{aligned} u_1 = v_1, & ~e_1 = \dfrac{u_1}{\Vert u_1 \Vert} \\ u_2 = v_2 - (v_2 \cdot e_1) e_1, &~e_2 = \dfrac{u_2}{\Vert u_2 \Vert} \\ v_{k+1} = v_{k+1} - (v_{k+1} \cdot e_1) e_1 - \dotsb-(v_{k+1} \cdot e_k)e_k,&~e_{k+1} = \dfrac{u_{k+1}}{\Vert u_{k+1} \Vert} \end{aligned}

A=[โˆฃ โ€ฆ โˆฃv1 โ€ฆ vnโˆฃ โ€ฆ โˆฃ]=[e1 โ€ฆ en]โŸQ[v1โ‹…e1v2โ‹…e1โ€ฆvnโ‹…e10v2โ‹…e2โ€ฆvnโ‹…e2โ‹ฎโ‹ฎโ‹ฑโ‹ฎ00โ€ฆvnโ‹…en]โŸR \begin{aligned} A & = \begin{bmatrix} \vert ~ & \dotsc & ~ \vert \\ v_1 ~ & \dotsc & ~ v_n \\ \vert ~ & \dotsc & ~ \vert \\ \end{bmatrix} \\ & =\underbrace{ [e_1 ~ \dotsc ~ e_n] }_{Q} \underbrace{ \begin{bmatrix} v_1 \cdot e_1 & v_2 \cdot e_1 & \dotsc & v_n \cdot e_1 \\ 0 & v_2 \cdot e_2 & \dotsc & v_n \cdot e_2 \\ \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & \dotsc & v_n \cdot e_n \\ \end{bmatrix}}_{R} \end{aligned}

Least quares solution

๋จผ์ € AโˆˆRmร—nA \in {\mathbb R}^{m \times n} (mโ‰ฅnm \geq n)์ด๋ผ๊ณ  ํ•˜์ž. ์ด๋•Œ ๋‹ค์Œ๊ณผ ๊ฐ™์€ QR ๋ถ„ํ•ด๊ฐ€ ์กด์žฌํ•˜๋‹ค.

A=Q[R0] A = Q \begin{bmatrix} R \\ 0 \end{bmatrix}

A=[Q1,Q2][R0]=Q1R A = [Q_1, Q_2] \begin{bmatrix} R \\ 0 \end{bmatrix} = Q_1 R

์ด์ œ ์ตœ์†Œ์ž์Šน๋ฒ•์˜ ๋ชฉ์ ํ•จ์ˆ˜๋ฅผ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์จ๋ณด์ž.

โˆฅAxโˆ’bโˆฅ22=โˆฅQT(Axโˆ’b)โˆฅ=โˆฅ[R0]xโˆ’QTbโˆฅ=โˆฅRxโˆ’d1โˆฅโŸ(โˆ—)+โˆฅd2โˆฅ \begin{aligned} \Vert A x - b \Vert^2_2 & = \Vert Q^T(Ax-b) \Vert \\ & = \Vert \begin{bmatrix} R \\ 0 \end{bmatrix} x - Q^T b \Vert \\ & = \underbrace{\Vert Rx - d_1 \Vert}_{(\ast)} + \Vert d_2 \Vert \end{aligned}

์ด๋•Œ โˆฅd2โˆฅ\Vert d_2 \Vert๋Š” ์ƒ์ˆ˜์ด๋ฏ€๋กœ, ๊ทน์†Œํ™” ๋ฌธ์ œ๋Š” (โˆ—)(\ast)๋ฅผ ์ตœ์†Œํ™”ํ•˜๋ฉด ๋œ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์ € ๊ฑฐ๋ฆฌ๋ฅผ ์ตœ์†Œํ™”ํ•ด์ฃผ๋Š” ๊ฒƒ์€ ๋‹น์—ฐํ•˜๊ฒŒ

x=Rโˆ’1d1 x = R^{-1} d_1

Singular Value Decomposition

M=UฮฃVโˆ— M = U \boldsymbol{\Sigma} V^*

Geometric interpretation

๊ธฐํ•˜ํ•™์ ์œผ๋กœ ํ•ด์„ํ•ด๋ณผ ์ˆ˜ ์žˆ๊ฒ ๋‹ค. ๋Œ€์ฒด๋กœ ์œ ๋‹ˆํ„ฐ๋ฆฌ ํ˜น์€ ์ง๊ต ํ–‰๋ ฌ๋“ค์„ ์„œ๋กœ ์ง๊ตํ•˜๋Š” ์ถ•์„ ํšŒ์ „ํ•˜๋Š” ์—ญํ• ์„ ํ•œ๋‹ค. ํ•œํŽธ, ์‹ค์ˆ˜๋กœ ๊ตฌ์„ฑ๋œ ๋Œ€๊ฐ ํ–‰๋ ฌ์„ ๋ฒกํ„ฐ์˜ ๊ธธ์ด๋ฅผ ๋Š˜์ด๊ณ  ์ค„์ด๋Š” ์—ญํ• ์„ ํ•œ๋‹ค. ์•„์šธ๋Ÿฌ SVD์—์„œ๋Š” ์ฐจ์›์„ ์กฐ์ •ํ•˜๋Š” ์—ญํ• ์„ ํ•œ๋‹ค. ์–ด๋–ค ์ถ•์€ ์—†์• ๊ธฐ๋„ ํ•˜๊ณ , ์—†๋˜ ์ถ•์„ ์ƒ์„ฑํ•˜๊ธฐ๋„ ํ•œ๋‹ค.

๋”ฐ๋ผ์„œ ์–ด๋–ค xโˆˆCnร—1x \in {\mathbb C}^{n \times 1}๊ฐ€ ์žˆ์„ ๋•Œ

Reduced SVD

Thin SVD

Compact SVD

Truncated SVD

์ด๋•Œ, raw, thin, compact๋Š” ์ •๋ณด์˜ ์†์‹ค์ด ์—†๋‹ค๋Š” ์ ์„ ์ƒ๊ธฐํ•˜์ž. Truncated ๋ถ€ํ„ฐ ์ •๋ณด์˜ ์†์‹ค์ด ๋ฐœ์ƒํ•œ๋‹ค.1

Pseudo-inverse

๋ณดํ†ต AโˆˆRmร—nA \in {\mathbb R}^{m \times n} (m>nm > n)์ธ ๊ฒฝ์šฐ ์—ญํ–‰๋ ฌ์„ ๊ตฌํ•  ์ˆ˜ ์—†๋‹ค. ์ด๋•Œ ์—ญํ–‰๋ ฌ๊ณผ ์ตœ๋Œ€ํ•œ ๋น„์Šทํ•œ ํ–‰๋ ฌ์„ ์ฐพ๋Š” ๊ฒƒ์ด ๋ชฉํ‘œ๋‹ค. ๋งŒ์ผ Ax=bAx = b์—์„œ ์—ญํ–‰๋ ฌ์ด ์กด์žฌํ•œ๋‹ค๋ฉด x=Aโˆ’1bx = A^{-1}b๋กœ ์‰ฝ๊ฒŒ ๊ตฌํ•  ์ˆ˜ ์žˆ๋‹ค. ํ•˜์ง€๋งŒ ์—ญํ–‰๋ ฌ์ด ์กด์žฌํ•˜์ง€ ์•Š๋Š”๋‹ค๋ฉด ์–ด๋–ค xx๋ฅผ ๊ตฌํ•˜๋Š” ๊ฒŒ ์ข‹์„๊นŒ? โˆฅAxโˆ’bโˆฅ\Vert Ax - b \Vert๋ฅผ ์ตœ์†Œํ™”ํ•˜๋Š” xx๋ฅผ ๊ตฌํ•œ๋‹ค๊ณ  ํ•  ๋•Œ, ์ด๋ฅผ ๋‹ฌ์„ฑํ•ด์ฃผ๋Š” A+A^+๋ฅผ AA์˜ ์œ ์‚ฌ์—ญํ–‰๋ ฌ์ด๋ผ๊ณ  ๋ถ€๋ฅธ๋‹ค. ์ฆ‰,

x=A+b x = A^+ b

SVD๋Š” ์ด ์œ ์‚ฌ์—ญํ–‰๋ ฌ์„ ๊ตฌํ•˜๋Š” ๊ณผ์ •์—์„œ ํ™œ์šฉ๋  ์ˆ˜ ์žˆ๋‹ค. ์ฆ‰, A=UฮฃVโˆ—A = U \boldsymbol{\Sigma} V^*์ด๋ผ๋ฉด A+=Vฮฃ+Uโˆ—A^+ = V \boldsymbol{\Sigma}^+ U^*๋ผ๊ณ  ๋‘˜ ์ˆ˜ ์žˆ๋‹ค. ์—ฌ๊ธฐ์„œ

A=UโŸmร—m[ฯƒ1 โ‹ฏ 0โ‹ฎ โ‹ฑ โ‹ฎ0 โ‹ฏ ฯƒs0  โ‹ฏ  0โ‹ฎ โ‹ฑ โ‹ฎ0  โ‹ฏ  0]โŸmร—nVTโŸnร—n A = \underbrace{U}_{m \times m} \underbrace{ \begin{bmatrix} \sigma_1 ~\dotsb~ 0 \\ \vdots ~ \ddots ~ \vdots \\ 0 ~\dotsb ~ \sigma_s \\ 0 ~~\dotsb ~~ 0 \\ \vdots ~ \ddots ~ \vdots \\ 0 ~~\dotsb ~~ 0 \\ \end{bmatrix} }_{m \times n} \underbrace{V^T}_{n \times n}

A+=VโŸnร—n[1ฯƒ1 โ‹ฏ 0 0 โ‹ฏ 0โ‹ฎ  โ‹ฑ  โ‹ฎ  0 โ‹ฏ 00 โ‹ฏ 1ฯƒs 0 โ‹ฏ 0]โŸnร—mUTโŸmร—m A^+ = \underbrace{V}_{n \times n} \underbrace{ \begin{bmatrix} \frac{1}{\sigma_1} ~\dotsb~ 0~0 ~ \dotsb ~ 0\\ \vdots ~~ \ddots ~~ \vdots ~~ 0 ~ \dotsb ~ 0 \\ 0 ~\dotsb ~ \frac{1}{\sigma_s} ~ 0 ~ \dotsb ~ 0 \\ \end{bmatrix} }_{n \times m} \underbrace{U^T}_{m \times m}

A+A=(Vฮฃ+UT)(UฮฃVT)=VVT=In A^+ A = ( V \boldsymbol{\Sigma}^+ U^T) (U \boldsymbol{\Sigma} V^T) = V V^T = I_n

AA+=(UฮฃVT)(Vฮฃ+UT)=UUT=Im AA^+ = (U \boldsymbol{\Sigma} V^T) ( V \boldsymbol{\Sigma}^+ U^T) = U U^T = I_m

Reference

https://darkpgmr.tistory.com/106




๐Ÿ lostineconomics.com | Jun Sok Huhh


  1. ์ด๋Ÿฐ ํŠน์„ฑ ๋•Œ๋ฌธ์— truncated SVD๋Š” ์ด๋ฏธ์ง€ ์••์ถ•์— ๋งŽ์ด ํ™œ์šฉ๋œ๋‹ค. ์—ฌ๊ธฐ์—์„œ ๊ทธ ์‚ฌ๋ก€๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. โ†ฉ๏ธŽ