线性最小二乘法原理推导

给定多组特征值与其对应的观测量情况下,求解系数A使式1值最小。
f ( x ) = ∑ j = 0 n − 1 a j x j (0) f(x) = \sum_{j=0}^{n-1}a_jx^{j} \tag0 f(x)=j=0n1ajxj(0)

E L S = ∑ i ∣ ∑ j = 0 n − 1 a j x i j − y i ∣ 2 = ∑ i ∣ A x i − y i ∣ 2 = ∥ X A − Y ∥ 2 (1) E_{LS} = \sum_{i}|\sum_{j=0}^{n-1}a_jx_i^{j} - y_i|^{2} = \sum_{i}|Ax_i - y_i|^{2} = \|XA - Y\|^{2} \tag1 ELS=ij=0n1ajxijyi2=iAxiyi2=XAY2(1)
其中A表示未知参数,向量模平方等价于向量內积,即
E L S = ( X A − Y ) T ( X A − Y ) (2) E_{LS} = (XA - Y)^T(XA - Y) \tag2 ELS=(XAY)T(XAY)(2)
方式一:
对A求微分,并根据微分与导数关系可得式3,式4,如下:
d E = ( X d A ) T ( X A − Y ) + ( X A − Y ) T ( X d A ) = 2 ( X A − Y ) T ( X d A ) (3) dE = (XdA)^T(XA - Y) + (XA - Y)^T(XdA) \\=2(XA - Y)^T(XdA)\tag3 dE=(XdA)T(XAY)+(XAY)T(XdA)=2(XAY)T(XdA)(3)
d E = δ E T δ A d A (4) dE = \frac{\delta E^T}{\delta A}dA \tag4 dE=δAδETdA(4)
综合式3与式4,可得对A偏导如式5
δ E δ A = 2 ( ( X A − Y ) T X ) T (5) \frac{\delta E}{\delta A} = 2((XA - Y)^TX)^T\tag5 δAδE=2((XAY)TX)T(5)
最后,由于最小平方差和对应着偏导数为0,由式5可得系数A
A = ( X T X ) − 1 X T Y (6) A = (X^TX)^{-1}X^TY\tag6 A=(XTX)1XTY(6)

方式二:
E L S = A T X T X A − Y T X A − A T X T Y + Y T Y = A T X T X A − 2 A T X T Y + Y T Y (7) E_{LS} = A^{T}X^{T}XA - Y^{T}XA - A^{T}X^{T}Y + Y^{T}Y \\= A^{T}X^{T}XA - 2A^{T}X^{T}Y + Y^{T}Y \tag7 ELS=ATXTXAYTXAATXTY+YTY=ATXTXA2ATXTY+YTY(7)
δ E δ A = 2 X T X A − 2 X T Y = 0 (8) \frac{\delta E}{\delta A} = 2X^{T}XA - 2X^{T}Y = 0\tag8 δAδE=2XTXA2XTY=0(8)
A = ( X T X ) − 1 X T Y (9) A = (X^{T}X)^{-1}X^{T}Y\tag9 A=(XTX)1XTY(9)

你可能感兴趣的:(数学知识,最小二乘法,机器学习,人工智能)