高斯牛顿法,LM法

Gauss–Newton algorithm

应用场景:The Gauss–Newton algorithm is used to solve non-linear least squares problems


高斯牛顿法的推导来自于牛顿法,Wiki的数学推导确实很清楚:

Derivation from Newton's method



Levenberg–Marquardt algorithm



(xi,yi)是一组观测数据,xi, yi是实数;β是我们要优化的变量,假设为n*1维:增量δ(向量)通过下式确定:

The sum of squares {\displaystyle S(\beta )}S(\beta ) at its minimum has a zero gradient with respect to β. The above first-order approximation of {\displaystyle f(x_{i},{\boldsymbol {\beta }}+{\boldsymbol {\delta }})}{\displaystyle f(x_{i},{\boldsymbol {\beta }}+{\boldsymbol {\delta }})} gives

{\displaystyle S({\boldsymbol {\beta }}+{\boldsymbol {\delta }})\approx \sum _{i=1}^{m}\left(y_{i}-f(x_{i},{\boldsymbol {\beta }})-J_{i}{\boldsymbol {\delta }}\right)^{2},}{\displaystyle S({\boldsymbol {\beta }}+{\boldsymbol {\delta }})\approx \sum _{i=1}^{m}\left(y_{i}-f(x_{i},{\boldsymbol {\beta }})-J_{i}{\boldsymbol {\delta }}\right)^{2},}

or in vector notation,

{\displaystyle {\begin{aligned}S({\boldsymbol {\beta }}+{\boldsymbol {\delta }})&\approx \|\mathbf {y} -\mathbf {f} ({\boldsymbol {\beta }})-\mathbf {J} {\boldsymbol {\delta }}\|^{2}\\&=[\mathbf {y} -\mathbf {f} ({\boldsymbol {\beta }})-\mathbf {J} {\boldsymbol {\delta }}]^{T}[\mathbf {y} -\mathbf {f} ({\boldsymbol {\beta }})-\mathbf {J} {\boldsymbol {\delta }}]\\&=[\mathbf {y} -\mathbf {f} ({\boldsymbol {\beta }})]^{T}[\mathbf {y} -\mathbf {f} ({\boldsymbol {\beta }})]-[\mathbf {y} -\mathbf {f} ({\boldsymbol {\beta }})]^{T}\mathbf {J} {\boldsymbol {\delta }}-(\mathbf {J} {\boldsymbol {\delta }})^{T}[\mathbf {y} -\mathbf {f} ({\boldsymbol {\beta }})]+{\boldsymbol {\delta }}^{T}\mathbf {J} ^{T}\mathbf {J} {\boldsymbol {\delta }}\\&=[\mathbf {y} -\mathbf {f} ({\boldsymbol {\beta }})]^{T}[\mathbf {y} -\mathbf {f} ({\boldsymbol {\beta }})]-2[\mathbf {y} -\mathbf {f} ({\boldsymbol {\beta }})]^{T}\mathbf {J} {\boldsymbol {\delta }}+{\boldsymbol {\delta }}^{T}\mathbf {J} ^{T}\mathbf {J} {\boldsymbol {\delta }}.\end{aligned}}}{\displaystyle {\begin{aligned}S({\boldsymbol {\beta }}+{\boldsymbol {\delta }})&\approx \|\mathbf {y} -\mathbf {f} ({\boldsymbol {\beta }})-\mathbf {J} {\boldsymbol {\delta }}\|^{2}\\&=[\mathbf {y} -\mathbf {f} ({\boldsymbol {\beta }})-\mathbf {J} {\boldsymbol {\delta }}]^{T}[\mathbf {y} -\mathbf {f} ({\boldsymbol {\beta }})-\mathbf {J} {\boldsymbol {\delta }}]\\&=[\mathbf {y} -\mathbf {f} ({\boldsymbol {\beta }})]^{T}[\mathbf {y} -\mathbf {f} ({\boldsymbol {\beta }})]-[\mathbf {y} -\mathbf {f} ({\boldsymbol {\beta }})]^{T}\mathbf {J} {\boldsymbol {\delta }}-(\mathbf {J} {\boldsymbol {\delta }})^{T}[\mathbf {y} -\mathbf {f} ({\boldsymbol {\beta }})]+{\boldsymbol {\delta }}^{T}\mathbf {J} ^{T}\mathbf {J} {\boldsymbol {\delta }}\\&=[\mathbf {y} -\mathbf {f} ({\boldsymbol {\beta }})]^{T}[\mathbf {y} -\mathbf {f} ({\boldsymbol {\beta }})]-2[\mathbf {y} -\mathbf {f} ({\boldsymbol {\beta }})]^{T}\mathbf {J} {\boldsymbol {\delta }}+{\boldsymbol {\delta }}^{T}\mathbf {J} ^{T}\mathbf {J} {\boldsymbol {\delta }}.\end{aligned}}}

Taking the derivative of {\displaystyle S({\boldsymbol {\beta }}+{\boldsymbol {\delta }})}{\displaystyle S({\boldsymbol {\beta }}+{\boldsymbol {\delta }})} with respect to δ and setting the result to zero gives

{\displaystyle (\mathbf {J} ^{T}\mathbf {J} ){\boldsymbol {\delta }}=\mathbf {J} ^{T}[\mathbf {y} -f({\boldsymbol {\beta }})],}{\displaystyle (\mathbf {J} ^{T}\mathbf {J} ){\boldsymbol {\delta }}=\mathbf {J} ^{T}[\mathbf {y} -f({\boldsymbol {\beta }})],}   实数对向量求导

where {\displaystyle \mathbf {J} }\mathbf {J}  is the Jacobian matrix,(m*n维) whose i-th row equals J_{i}, and where \mathbf f (m*1维)and \mathbf {y}  (m*1维)are vectors with i-th component {\displaystyle f(x_{i},{\boldsymbol {\beta }})} and y_{i} respectively. This is a set of linear equations, which can be solved for δ.



从这看到增量的求解是这样的过程:

目标函数是S(\beta ), 对自变量  β 产生一个增量δ,新的目标函数S(β+δ)的近似表达式 增量 δ求导,令导数为0得到的。

这么求增量 β的原因是不是这么理解:

假设 β ^是使得S(\beta )最小的值,如何求得最优解  β ^呢?  换句话说,在初值β0的基础上,如何确定一个增量δ,使得S(\beta )最小?

逆向考虑:假设我们已经得到了这个增量δ,那必然 S’(β0+δ) =0。

现在的问题是如何求δ,即 δ是未知量。 而 δ又满足  S’(β0+δ) =0,要求 δ,那只有S(β0+δ)对 δ求导,令其导数为0得到




Levenberg's contribution is to replace this equation by a "damped version",

{\displaystyle (\mathbf {J} ^{T}\mathbf {J} +\lambda \mathbf {I} ){\boldsymbol {\delta }}=\mathbf {J} ^{T}[\mathbf {y} -\mathbf {f} ({\boldsymbol {\beta }})],}{\displaystyle (\mathbf {J} ^{T}\mathbf {J} +\lambda \mathbf {I} ){\boldsymbol {\delta }}=\mathbf {J} ^{T}[\mathbf {y} -\mathbf {f} ({\boldsymbol {\beta }})],}

where I is the identity matrix, giving as the increment δ to the estimated parameter vector β.



猜测可能需要计算   || S(β+δ)-S(β) ||  是否超过某一个阈值. If 超过阈值,减小λ ;else,增大λ

The (non-negative) damping factor λ is adjusted at each iteration. If reduction of S is rapid, a smaller value can be used, bringing the algorithm closer to the Gauss–Newton algorithm, whereas if an iteration gives insufficient reduction in the residual, λ can be increased, giving a step closer to the gradient-descent direction. 

 If either the length of the calculated step δ or the reduction of sum of squares from the latest parameter vector β + δ fall below predefined limits, iteration stops, and the last parameter vector β is considered to be the solution.



Levenberg's algorithm has the disadvantage thatif the value of damping factor λ is large, inverting JTJ + λI is not used at all. Marquardt provided the insight that we can scale each component of the gradient according to the curvature(曲率), so that there is larger movement along the directions where the gradient is smaller. This avoids slow convergence in the direction of small gradient. Therefore, Marquardt replaced the identity matrix I with the diagonal matrix consisting of the diagonal elements of JTJ, resulting in the Levenberg–Marquardt algorithm:

{\displaystyle [\mathbf {J} ^{T}\mathbf {J} +\lambda \operatorname {diag} (\mathbf {J} ^{T}\mathbf {J} )]{\boldsymbol {\delta }}=\mathbf {J} ^{T}[\mathbf {y} -\mathbf {f} ({\boldsymbol {\beta }})].}{\displaystyle [\mathbf {J} ^{T}\mathbf {J} +\lambda \operatorname {diag} (\mathbf {J} ^{T}\mathbf {J} )]{\boldsymbol {\delta }}=\mathbf {J} ^{T}[\mathbf {y} -\mathbf {f} ({\boldsymbol {\beta }})].}

L-M方法的一些实现库,全部的见wiki


The GNU Scientific Library has a C interface to MINPACK.

C/C++ Minpack includes the Levenberg–Marquardt algorithm

levmar is an implementation in C/C++ with support for constraints

sparseLM is a C implementation aimed at minimizing functions with large, arbitrarily sparse Jacobians. Includes a MATLAB MEX interface

InMin library contains a C++ implementation of the algorithm based on the eigen C++ linear algebra library. It has a pure C-language API as well as a Python binding

ceres is a non-linear minimisation library with an implementation of the Levenberg–Marquardt algorithm. It is written in C++ and uses eigen

ALGLIB has implementations of improved LMA in C# / C++ / Delphi / Visual Basic. Improved algorithm takes less time to converge and can use either Jacobian or exact Hessian.




<think>嗯,用户想了解高斯牛顿法的原理和应用,还有数值优化方面的内容。首先,我需要回顾一下高斯牛顿法的基础知识。高斯牛顿法是非线性最小二乘问题中的常用优化方,通常用于数据拟合和参数估计。记得它是对牛顿法的改进,避免了计算Hessian矩阵的高成本。 根据引用[1],高斯牛顿法用雅可比矩阵的乘积来近似Hessian矩阵,这样计算量就减少了。而牛顿法需要计算二阶导数,这在多维情况下非常麻烦。所以高斯牛顿法的核心思想就是用一阶信息来近似二阶信息,从而简化计算。 接下来,用户可能想知道具体的原理。根据引用[3],高斯牛顿法处理的是最小化残差平方和的问题。残差函数的线性近似是通过泰勒展开实现的,然后用这个近似来构建目标函数,进而求解参数更新量。这时候需要解一个线性方程组,通常是使用雅可比矩阵的转置乘以自身加上阻尼因子(如果考虑LM算法的话)。 不过,用户提供的引用[2]提到高斯牛顿法的缺陷,比如矩阵可能不可逆或者病态,导致算法不收敛。这时候可能需要引入LM算法,通过调整阻尼因子来保证矩阵的正定性,从而改善稳定性。所以在讲解应用的时候,应该提到这些限制以及改进方。 在应用部分,需要举一些实际的例子,比如曲线拟合、计算机视觉中的Bundle Adjustment,或者机器人中的状态估计。这些都是高斯牛顿法的典型应用场景。同时,数值优化中的参数估计问题,比如非线性回归,也是常见的用途。 数值优化方面,用户可能关心高斯牛顿法与其他方的对比,比如梯度下降牛顿法LM算法等。需要比较它们的优缺点,比如收敛速度、计算复杂度、稳定性等。引用[1]和[2]已经提到了高斯牛顿法在计算上的优势以及可能的稳定性问题,这些都要在回答中体现出来。 另外,用户的问题中提到了生成相关问题,可能需要包括高斯牛顿法的优化策略、与其他算法的比较、实际应用案例、实现时的注意事项等。这些问题可以帮助用户进一步深入理解。 需要注意的是,用户提供的引用中有一些数学公式的格式要求,比如行内公式用$...$,独立公式用$$...$$,并且要正确使用LaTeX语。所以在回答时要确保公式的正确性,比如残差函数的表示、目标函数的形式、雅可比矩阵的构造等。 最后,要确保回答结构清晰,分点讲解原理、步骤、优缺点、应用场景,并自然地插入引用标记。可能还需要在相关问题上引导用户探索更深入的内容,比如如何处理病态矩阵,或者如何实现高斯牛顿法的代码。 总结一下,回答的结构应该是:首先介绍高斯牛顿法的背景和适用问题类型,然后详细讲解其数学原理和步骤,接着分析优缺点,再列举应用场景,最后与其他方进行对比,并生成相关问题。同时,注意引用标记的正确位置,比如在提到Hessian矩阵近似时引用[1],在讨论收敛性问题时引用[2],在推导算法时引用[3]。</think>### 高斯-牛顿法详解 #### 一、原理与数学基础 高斯-牛顿法是一种针对**非线性最小二乘问题**的优化算法,其目标是求解: $$ \min_x \sum_{i=1}^m [r_i(x)]^2 $$ 其中 $x \in \mathbb{R}^n$ 为待优化参数,$r_i(x)$ 为残差函数。通过**泰勒展开对残差函数线性化**,将原问题转化为线性最小二乘问题[^3]。 **核心步骤**: 1. **残差线性近似**:对 $r_i(x)$ 在 $x_k$ 处进行一阶泰勒展开: $$ r_i(x_k + \Delta x) \approx r_i(x_k) + J_i(x_k)\Delta x $$ 其中 $J_i(x_k)$ 是残差函数在 $x_k$ 处的雅可比矩阵。 2. **构建目标函数**:原问题近似为: $$ \min_{\Delta x} \sum_{i=1}^m [r_i(x_k) + J_i(x_k)\Delta x]^2 $$ 3. **求解增量**:通过正规方程 $J^T J \Delta x = -J^T r$ 计算参数更新量 $\Delta x$[^1]。 #### 二、特点与改进 - **优势**: - 避免直接计算Hessian矩阵,仅需雅可比矩阵 $J$,计算效率高[^1]。 - 适用于残差函数可线性化的非线性问题。 - **缺陷**: - 当 $J^T J$ **不可逆或病态**时,算法可能不收敛[^2]。 - 步长过大时局部近似失效,导致目标函数值增大。 - **改进方**:引入**LM算法(Levenberg-Marquardt)**,通过添加阻尼因子 $\mu$ 保证矩阵正定性: $$ (J^T J + \mu I)\Delta x = -J^T r $$ #### 三、应用场景 1. **曲线拟合**:如指数衰减模型 $y = a e^{-bx}$ 的参数估计。 2. **计算机视觉**:Bundle Adjustment 用于多视图几何优化。 3. **机器人定位**:SLAM(同步定位与建图)中的状态估计。 4. **经济学模型**:非线性回归分析中的参数校准。 #### 四、与其他算法的对比 | 算法 | 计算复杂度 | 收敛速度 | 稳定性 | |--------------|------------|----------|--------------| | 梯度下降 | 低 | 线性 | 高 | | 牛顿法 | 高 | 二次 | 依赖Hessian | | 高斯-牛顿法 | 中 | 超线性 | 依赖 $J^T J$ | | LM算法 | 中 | 超线性 | 高 | #### 五、代码实现框架(C语言伪代码) ```c void gauss_newton(double x[], int max_iter, double tol) { for (int k = 0; k < max_iter; k++) { compute_residuals(r, x); // 计算残差向量r compute_jacobian(J, x); // 计算雅可比矩阵J solve(J^T * J, -J^T * r, dx); // 解线性方程组 x += dx; // 更新参数 if (norm(dx) < tol) break; // 收敛判断 } } ```
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值