线性代数笔记15--投影矩阵和最小二乘法
1. 投影矩阵
投影矩阵
P=A(A⊤A)−1A⊤
P=A(A^{\top}A)^{-1}A^{\top}
P=A(A⊤A)−1A⊤
p=Pbp=Pbp=Pb
- 当b⊥C(A)b\perp C(A)b⊥C(A),p=A(A⊤A)−1A⊤b=0;p=0p=A(A^{\top}A)^{-1}A^{\top}b=0;p=0p=A(A⊤A)−1A⊤b=0;p=0
- 当b∈C(A),AX=b,p=A(A⊤A)−1A⊤AX=A{(A⊤A)−1A⊤A}X=AX=bb\in C(A),AX=b,p=A(A^{\top}A)^{-1}A^{\top}AX=A\{(A^{\top}A)^{-1}A^{\top}A\}X=AX=bb∈C(A),AX=b,p=A(A⊤A)−1A⊤AX=A{(A⊤A)−1A⊤A}X=AX=b

- 其他情况
b=p+eb=p+eb=p+e
p=Pbp=Pbp=Pb
e=(I−P)be=(I-P)be=(I−P)b
证明:当AAA的各列线性无关时,A⊤AA^{\top}AA⊤A可逆。
假设A⊤AX=0,我们只需要证明X=0。A⊤AX=0 ⟺ X⊤A⊤AX=X⊤0=0(AX)⊤AX=0 ⟺ y⊤y=0y⊤y=0⇒y=0 ⟺ AX=0因为A各列线性无关,所以X=0 \begin{align} &假设A^{\top}AX=0,我们只需要证明X=0。 \nonumber\\ &A^{\top}AX=0 \iff X^{\top}A^{\top}AX=X^{\top}0 =0 \nonumber \\ &(AX)^{\top}AX=0 \nonumber \iff y^{\top}y=0\\ \nonumber &y^{\top}y=0 \Rightarrow y=0 \iff AX=0 \nonumber \\ &因为A各列线性无关,所以X=0 \nonumber \end{align} 假设A⊤AX=0,我们只需要证明X=0。A⊤AX=0⟺X⊤A⊤AX=X⊤0=0(AX)⊤AX=0⟺y⊤y=0y⊤y=0⇒y=0⟺AX=0因为A各列线性无关,所以X=0
2. 最小二乘法
给出三个点(1,1),(2,2),(3,2)(1,1),(2,2),(3,2)(1,1),(2,2),(3,2),让拟合成直线y=C+Dty=C+Dty=C+Dt的形式。

拟合直线实际上就是
min∣∣AX−b∣∣2=∣∣e∣∣2=e12+e22+e32
\min \vert|AX-b|\vert^{2}=||e||^{2}=e_1^{2}+e_2^{2}+e_3^{2}
min∣∣AX−b∣∣2=∣∣e∣∣2=e12+e22+e32
先根据点和直线方程写出对应的矩阵
C+D=1C+2D=2C+3D=2
C+D=1\\C+2D=2\\C+3D=2
C+D=1C+2D=2C+3D=2
AX=bA=[111213]X=[CD]b=[122]
AX=b\\
A=
\begin{bmatrix}
1 & 1\\1 & 2\\ 1 & 3
\end{bmatrix}\\
X=
\begin{bmatrix}
C\\D
\end{bmatrix}\\
b=
\begin{bmatrix}
1 \\ 2\\ 2
\end{bmatrix}
AX=bA=111123X=[CD]b=122
根据投影公式,我们先来求投影在列空间上的
X^=[C^D^]
\hat{X}=
\begin{bmatrix}
\hat{C}\\\hat{D}
\end{bmatrix}
X^=[C^D^]
AX^=pe=b−p=b−AX^e⊥AA⊤(b−AX^)=0A⊤AX^=A⊤b
A\hat{X}=p\\
e=b-p=b-A\hat{X}\\
e \perp A\\
A^{\top}(b-A\hat{X})=0\\
A^{\top}A\hat{X}=A^{\top}b
AX^=pe=b−p=b−AX^e⊥AA⊤(b−AX^)=0A⊤AX^=A⊤b
A⊤A=[111123][111213]=[36614]
A^{\top}A=
\begin{bmatrix}
1 & 1 & 1\\
1 & 2 & 3\\
\end{bmatrix}
\begin{bmatrix}
1 & 1 \\
1 & 2 \\
1 & 3\\
\end{bmatrix}=
\begin{bmatrix}
3 & 6\\
6 & 14\\
\end{bmatrix}
A⊤A=[111213]111123=[36614]
A⊤A可逆A^{\top}A可逆A⊤A可逆
A⊤b=[111123][122]=[511] A^{\top}b= \begin{bmatrix} 1 & 1 & 1\\ 1 & 2 & 3\\ \end{bmatrix} \begin{bmatrix} 1 \\ 2 \\2 \end{bmatrix}= \begin{bmatrix} 5\\11 \end{bmatrix} A⊤b=[111213]122=[511]
近似方程
[36614][C^D^]=[511] ⟺ {3C^+6D^=52C^+14D^=11C^=23D^=12y=1/2t+2/3
\begin{bmatrix}
3 & 6\\
6 & 14\\
\end{bmatrix}\begin{bmatrix}
\hat{C}\\\hat{D}
\end{bmatrix}=
\begin{bmatrix}
5\\11
\end{bmatrix} \iff
\begin{cases}
&3\hat{C}+6\hat{D}=5\\
& 2\hat{C}+14\hat{D}=11
\end{cases}\\
\hat{C}=\frac{2}{3}\\
\hat{D}=\frac{1}{2}\\
y=1/2t+2/3
[36614][C^D^]=[511]⟺{3C^+6D^=52C^+14D^=11C^=32D^=21y=1/2t+2/3
- 微积分求法
E(C,D)=e12+e22+e32=(C+D−1)2+(C+2D−2)2+(C+3D−2)2∂E(C,D)∂C=6C+12D−10∂E(C,D)∂D=12C+28D−22 6C+12D−10=012C+28D−22=0
\begin{align}
& E(C,D)=e_1^2+e_2^2+e_3^2=(C+D-1)^{2}+(C+2D-2)^2+(C+3D-2)^2 \nonumber\\
&\frac{\partial{E(C,D)}}{\partial C} =6C+12D- 10\nonumber\\
&\frac{\partial E(C,D)}{\partial D}=12C + 28D -22\nonumber
\end{align}
\\
\begin{align}
\ 6C+12D-10=0 \nonumber \\
12C+28D-22=0 \nonumber \\
\end{align}
E(C,D)=e12+e22+e32=(C+D−1)2+(C+2D−2)2+(C+3D−2)2∂C∂E(C,D)=6C+12D−10∂D∂E(C,D)=12C+28D−22 6C+12D−10=012C+28D−22=0
偏导为0时,取得最小值;也可以计算出其最小值。
C^=23D^=12y=1/2t+2/3
\hat{C}=\frac{2}{3}\\
\hat{D}=\frac{1}{2}\\
y=1/2t+2/3
C^=32D^=21y=1/2t+2/3
可以求出替代点p1=(1,76),p2=(2,53),p3=(3,136)p_1=(1, \frac{7}{6}),p_2=(2,\frac{5}{3}),p_3=(3,\frac{13}{6})p1=(1,67),p2=(2,35),p3=(3,613)
这样可以得到误差
e=[e1e2e3]=[−1613−16]p=[p1p2p3]=[7653−136]e=
\begin{bmatrix}
e_1\\e_2\\e_3
\end{bmatrix}=
\begin{bmatrix}
-\frac{1}{6}\\\frac{1}{3}\\-\frac{1}{6}
\end{bmatrix}\\
p=\begin{bmatrix}
p_1\\p_2\\p_3
\end{bmatrix}=
\begin{bmatrix}
\frac{7}{6}\\\frac{5}{3}\\-\frac{13}{6}
\end{bmatrix}
e=e1e2e3=−6131−61p=p1p2p3=6735−613
e+p=be⊥p
e+p=b\\
e \perp p
e+p=be⊥p
更多推荐


所有评论(0)