最小二乘法用于在回归分析中,计算overdetemined system的近似解。overdetemined system是指等式数目多余未知量的问题。其思想是:最小化各个等式的误差的平方和。
最常见应用于数据拟合(如下),此时优化目标是最小化平方残差,残差即为观测值和模型计算的拟合值的差。
按照残差项是够是线性的,最小二乘法分为两类:线性最小二乘、非线性最小二乘。
线性最小二乘常见于回归分析,它有封闭的解(解具有等式形式,如 );非线性最小二乘通常是迭代寻优,每一次迭代中,将问题近似为线性。
最小二乘问题的数学表示:
其中 为模型, 如直线拟合中:
为模型参数向量,观察值为
为问题的目标函数,最小化平方和,即寻找梯度为0的解,设有m个参数,则有:
, 其中
.
带入 , 得到:
,
(1)
模型是参数的线性组合, , 其中
是x的函数(它是一个确定值)。所以:
将 带入(1)式子,得到矩阵形式:
其中
是正定矩阵,所有:
并不存在上述类似的封闭解,而是采用数字算法来寻优, 为参数设置初值,然后进行迭代调优,直至收敛。
, k为迭代的次数
称为 shift vector,位移向量。
每一次迭代,模型可以用关于 的Taylor一阶展开进行线性近似:
J是确定数值的Jacobian矩阵(独立于y和参数β)。
由此得:
最小化上式,梯度为0,得:
(2)
将 带入(2)式,得到结果的矩阵形式:
所以:
这就是Gauss–Newton algorithm的等式。
The Gauss–Newton algorithm is used to solve non-linear least squares problems. It is a modification of Newton‘s method for finding a minimum of a function. Unlike Newton‘s method, the Gauss–Newton algorithm can only be used to minimize a sum of squared function values, but it has the advantage that second derivatives, which can be challenging to compute, are not required.
参考:
https://en.wikipedia.org/wiki/Least_squares
https://en.wikipedia.org/wiki/Gauss%E2%80%93Newton_algorithm
原文:http://www.cnblogs.com/houkai/p/6369870.html