Proba ML
7. Linear Algebra
7.6 Other Matrix Decompositions

7.6 Other matrix decompositions

7.6.1 LU Factorization

We can factorize any square matrix AA into a lower and upper triangle matrix LL and UU:

Screen Shot 2023-03-26 at 19.17.37.png

We might need to reorder the rows at each iteration so that the first element of AA is non-zero: if a11=l11u11=0a_{11}=l_{11}u_{11}=0 then either UU or LL is singular.

PA=LUPA=LU

where PP is a permutation matrix, i.e. a square binary matrix where aij=1a_{ij}=1 means permuting row ii with row jj.

7.6.2 QR Decomposition

Suppose we have A∈Rm×nA\in\mathbb{R}^{m\times n} a set of linearly independent basis vectors. We want to find a series of orthonormal vectors q1,q2,…\bold{q}_1,\bold{q}_2,\dots that span the successive subspace of span(a1),span(a1,a2),…\mathrm{span}(\bold{a}_1),\mathrm{span}(\bold{a}_1, \bold{a}_2),\dots

Screen Shot 2023-03-26 at 19.26.46.png

We have:

a1=q1r11a2=q1r12+q2r22⋮an=q1r1n+⋯+qnrnn\begin{align} \bold{a}_1&=\bold{q}_1 r_{11}\\ \bold{a}_2&=\bold{q}_1 r_{12} + \bold{q}_2 r_{22}\\ \vdots \\ \bold{a}_n&=\bold{q}_1 r_{1n}+\dots+\bold{q}_nr_{nn} \end{align}

and thus:

A=QRA=QR

with Q∈Rm×nQ \in \mathbb{R}^{m\times n} and R∈Rn×nR \in \mathbb{R}^{n\times n}

7.6.3 Cholesky decomposition

Any symmetric positive definite matrix can be decomposed as A=LL⊤A=LL^\top where LL is a lower triangular with real, positive diagonal elements. The complexity is O(V3)O(V^3).

7.6.3.1 Application: sampling from an MVN

Let y∼N(μ,Σ)y\sim \mathcal{N}(\mu,\Sigma). We can easily sample from x∼N(0,I)x \sim \mathcal{N}(0, I) since it requires sampling from dd separate 1d Gaussians.

Let Σ=LL⊤\Sigma=LL^\top, we then set y=Lx+μy=Lx+\mu.

We can check that:

Cov[y]=LCov[x]L⊤=LIL⊤=ΣCov[y]=LCov[x]L^\top=LI L^\top=\Sigma