# 非线性最小二乘

非线性最小二乘是一种参数估计方法：对于在参数上非线性的模型，选择使模型预测与观测数据之间残差平方和最小的参数。它把线性最小二乘回归推广到一大类函数：几乎任何能以闭式写出的函数都可以作为模型，而对参数如何进入模型的限制很少。<sup>[1](https://www.itl.nist.gov/div898/handbook/pmd/section1/pmd142.htm)</sup>

| 关键事实 | 详情 |
|---|---|
| 模型形式 | \( y = f(\vec{x};\vec{\beta}) + \varepsilon \)，其中函数对未知参数 \( \beta_0, \beta_1, \ldots \) 不是线性的，而由最小二乘给出估计<sup>[1](https://www.itl.nist.gov/div898/handbook/pmd/section1/pmd142.htm)</sup> |
| 求解方法 | 需要迭代优化；与线性模型不同，参数估计一般无法解析获得<sup>[1](https://www.itl.nist.gov/div898/handbook/pmd/section1/pmd142.htm)</sup> |
| 标准算法 | 高斯-牛顿（Gauss-Newton）迭代及其阻尼变体——莱文贝格-马夸特算法，由肯尼斯·莱文贝格（Kenneth Levenberg）于1944年、唐纳德·马夸特（Donald Marquardt）于1963年提出<sup>[2](https://eclass.aueb.gr/modules/document/file.php/MISC249/Sauer%20-%20Numerical%20Analysis%202e.pdf)</sup><sup> • </sup><sup>[3](https://www.nist.gov/publications/fitting-natures-basic-functions-part-iii-exponentials-sinusoids-and-nonlinear-least)</sup> |
| 初值 | 必须相当接近真实估计，否则过程可能不收敛，或停留在局部极小值而非全局极小值<sup>[1](https://www.itl.nist.gov/div898/handbook/pmd/section1/pmd142.htm)</sup> |
| 典型应用 | 酶动力学（米凯利斯-门滕）、估计IC50的剂量-反应曲线、轨道确定，以及光束法平差等机器人与视觉问题<sup>[4](https://www.nature.com/articles/nprot.2009.182)</sup><sup> • </sup><sup>[5](https://doi.org/10.1007/s11538-024-01274-4)</sup><sup> • </sup><sup>[6](https://link.springer.com/article/10.1007/s12567-024-00535-1)</sup><sup> • </sup><sup>[7](https://www.mdpi.com/2218-6581/9/3/51)</sup> |
| 统计推断 | 置信区间、预测区间和校准区间已有成熟理论，不过其概率解释一般只是近似正确<sup>[1](https://www.itl.nist.gov/div898/handbook/pmd/section1/pmd142.htm)</sup> |

## 问题

非线性最小二乘问题取一组观测 \( (x_i, y_i) \) 和一个依赖于参数 \( \vec{\beta} \) 的模型函数 \( f \)，寻找使残差平方和最小的参数值，

\[ S(\vec{\beta}) = \sum_{i} \left( y_i - f(x_i; \vec{\beta}) \right)^{2}. \]

其决定性特征在于对参数的非线性，而不在于对预测变量的非线性。抛物线 \( y = a + b \cdot x + c \cdot x^{2} \) 是 \( x \) 的非线性函数，但由于参数 \( a \)、\( b \)、\( c \) 以各项的简单乘数形式进入相加的式子，拟合它仍是一个具有解析解的线性曲线拟合问题。相比之下，诸如 \( f(x;\vec{\beta}) = \beta_1 x^{\beta_2} \) 或 \( f(x;\vec{\beta}) = \beta_0 + \beta_1 \exp(-\beta_2 x) \) 的模型，其参数位于非线性运算内部，一般不存在闭式极小点。<sup>[1](https://www.itl.nist.gov/div898/handbook/pmd/section1/pmd142.htm)</sup><sup> • </sup><sup>[8](https://statpages.info/nonlin.html)</sup>

从业者偏好对参数光滑且最小二乘准则有唯一解的模型，尽管这些性质并不属于定义的一部分；它们之所以重要，是因为能使数值估计更容易。<sup>[1](https://www.itl.nist.gov/div898/handbook/pmd/section1/pmd142.htm)</sup>

## 算法

**高斯-牛顿。** 高斯-牛顿法在当前参数估计附近将残差线性化，并在每一步求解一个线性最小二乘问题，从而产生非线性模型的一系列线性近似。<sup>[9](https://cpoli.github.io/mathematicskit/history/optimization_breakthroughs.html)</sup><sup> • </sup><sup>[10](https://web.eecs.umich.edu/~fessler/book/c-ox.pdf)</sup> 这在解附近效果很好，但远离解时可能表现不佳。

**莱文贝格-马夸特。** 1944年，肯尼斯·莱文贝格建议在高斯-牛顿方程组中给 \( A^{T}A \) 加上 \( \lambda I \) 以改善其条件数；马夸特1963年发表于美国工业与应用数学学会的论文将这一想法发展成如今最常与非线性最小二乘拟合联系在一起的算法。<sup>[2](https://eclass.aueb.gr/modules/document/file.php/MISC249/Sauer%20-%20Numerical%20Analysis%202e.pdf)</sup><sup> • </sup><sup>[11](https://epubs.siam.org/doi/pdf/10.1137/0111030?download=true)</sup> 阻尼项在极小值附近的快速高斯-牛顿步与当前估计远离极小值时的类最速下降步之间进行插值；当阻尼很强（\( \lambda \gg 0 \)）时，阻尼占主导，方法趋近于梯度法。<sup>[12](https://academic.oup.com/gji/article/133/2/341/578128)</sup> 高斯-牛顿法的全局收敛变体——其中莱文贝格-马夸特方法和信赖域方法是两种成熟的范式——常常是这类问题的首选方法。<sup>[13](https://epubs.siam.org/doi/10.1137/20M1366253)</sup>

**信赖域方法。** 莱文贝格-马夸特算法给出信赖域子问题的精确解，但每次迭代通常比近似方法代价更高，因为它可能需要针对不同的信赖域参数值多次求解最小二乘方程组。鲍威尔（Powell）的狗腿法（dogleg method）将搜索限制在一条分段线性路径上，从而找到近似解；该路径从原点出发，经过柯西点（沿最速下降方向的极小点），到达高斯-牛顿点（局部二次模型的无约束极小点）。<sup>[14](https://www.gnu.org/software/gsl/doc/html/nls.html)</sup>

## 初值与局部极小值

由于估计是迭代的，用户必须在软件开始前提供初值。这些初值必须相当接近未知估计，否则优化可能不收敛；糟糕的初值还可能导致收敛到局部极小值，而不是定义最小二乘估计的全局极小值。<sup>[1](https://www.itl.nist.gov/div898/handbook/pmd/section1/pmd142.htm)</sup> 敏感性因模型而异：有些模型对初值选择相对不敏感，另一些则极为敏感；拟合过类似模型的先前数据集可以作为参考。<sup>[15](https://itl.nist.gov/div898/handbook/pmd/section6/pmd632.htm)</sup>

这种困难是问题类别所固有的。根据美国国家标准与技术研究院（NIST）非线性回归基准测试集，非线性最小二乘问题具有内在困难；即使对最稳健的代码，通常也能构造出使其失败的数据集；当初始值相距很远时，次级局部极小值会使问题格外困难。由于这些过程不保证找到全局极小值，落入不同的局部极小值并不视为求解器失败，不过应通过在新解附近重新启动来核查。<sup>[16](https://itl.nist.gov/div898/strd/nls/nls_info.shtml)</sup> 在基准问题上，好的过程应能将认证结果复现到至少4或5位数字。<sup>[16](https://itl.nist.gov/div898/strd/nls/nls_info.shtml)</sup>

## 实际工作流程

常见工作流程从绘制数据图开始，因为图往往提示一种已知的函数形式；科学知识、理论模型或拟合过类似已发表数据的函数可提供进一步指导，而试错则填补剩余空白。<sup>[15](https://itl.nist.gov/div898/handbook/pmd/section6/pmd632.htm)</sup> 变量变换可以简化拟合问题：取对数可使某些指数模型线性化，不过参数随后可能进入对数内部，使问题仍为本质非线性。<sup>[8](https://statpages.info/nonlin.html)</sup>

不需要专门软件。凯默（Kemmer）和凯勒（Keller）在《自然·实验手册》（Nature Protocols）（2010）中描述了一套完全在微软 Excel（Microsoft Excel）中执行非线性最小二乘拟合的方案：将实验数据和由回归方程计算的值绘制在工作表中，计算残差平方和，并用规划求解加载项将其最小化以获得最佳拟合参数，同时以可视方式评估最佳拟合值的置信度。该方案以简单酶动力学的米凯利斯-门滕（Michaelis-Menten）方程为例，不需要编程经验或额外软件成本。<sup>[4](https://www.nature.com/articles/nprot.2009.182)</sup> 标准科学计算库也提供直接例程，例如 SciPy 中的 `curve_fit`<sup>[17](https://pythonnumericalmethods.studentorg.berkeley.edu/notebooks/chapter16.05-Least-Square-Regression-for-Nonlinear-Functions.html)</sup> 和 MATLAB 中的 `lsqcurvefit`，后者需要拟合函数和初始参数估计。<sup>[18](https://www.mathworks.com/help/optim/ug/nonlinear-curve-fitting-with-lsqcurvefit.html)</sup>

## 为何使用

主要优点是可拟合函数的范围很广。许多科学和工程过程本质上是非线性的，而线性模型无法描述趋于渐近的过程，因为当解释变量趋于极端时，线性函数不能以递减的速率增加或减少。<sup>[1](https://www.itl.nist.gov/div898/handbook/pmd/section1/pmd142.htm)</sup> 非线性模型还能给出有理论依据、可直接解释的参数：在一项关于莱蒂萨酸（laetisaric acid）对抗植物病原体终极腐霉（*P. ultimum*）的剂量-反应研究中，研究目标是估计抑制生长50%的浓度，而非线性模型直接估计该半最大抑制浓度（IC50），而不是通过多项式回归中任意的二次项来估计。<sup>[5](https://doi.org/10.1007/s11538-024-01274-4)</sup>

作为一种估计框架，非线性最小二乘为最大似然提供了一种替代方案。它更普遍适用，因为只要软件能够指定概率函数，就可以对任何分布生成最小二乘估计；而且许多不支持最大似然估计的统计软件包也提供该方法。其缺点在于：该方法不易处理删失数据；其最优性性质通常被认为不如最大似然；结果可能严重依赖所选的初值。<sup>[19](https://www.itl.nist.gov/div898/handbook/eda/section3/eda3653.htm)</sup>

与线性最小二乘一样，该方法对离群值非常敏感：一两个离群值就可能严重影响结果；而且用于检测非线性回归中离群值的模型验证工具比线性回归少。<sup>[1](https://www.itl.nist.gov/div898/handbook/pmd/section1/pmd142.htm)</sup>

## 应用

非线性最小二乘是科学与工程中估计的基础。除酶动力学和剂量-反应曲线外，它还用于将高斯峰、指数衰减和正弦波拟合到时间序列，例如化石燃料二氧化碳排放和全球温度记录。<sup>[3](https://www.nist.gov/publications/fitting-natures-basic-functions-part-iii-exponentials-sinusoids-and-nonlinear-least)</sup>

在机器人和计算机视觉中，非线性最小二乘构成许多系统的基础：迭代最近点配准、投影配准、光束法平差和位姿图优化等问题都被表述为因子图上的迭代最小二乘问题；当传感器噪声为高斯噪声时，解由高斯-牛顿变体计算。<sup>[7](https://www.mdpi.com/2218-6581/9/3/51)</sup> 光束法平差被描述为同时定位与建图问题的最优非线性最小二乘表述，其最大似然形式与克拉美-罗（Cramer-Rao）下界相匹配。<sup>[20](https://www.microsoft.com/en-us/research/publication/adaptive-relative-bundle-adjustment/)</sup> 基于图的定位方法同样将建图表示为图上的稀疏非线性最小二乘问题。<sup>[21](https://doi.org/10.1007/s41315-026-00528-9)</sup>

在航天动力学中，非线性最小二乘方法通过迭代搜索使计算出的观测残差平方和最小的平均轨道状态来精化轨道状态；这种方法用于空间监视与跟踪软件。<sup>[6](https://link.springer.com/article/10.1007/s12567-024-00535-1)</sup>

## References

1. [Nonlinear Least Squares Regression, NIST/SEMATECH e-Handbook of Statistical Methods](https://www.itl.nist.gov/div898/handbook/pmd/section1/pmd142.htm)
2. [Sauer, Numerical Analysis, 2nd ed. (Levenberg-Marquardt section)](https://eclass.aueb.gr/modules/document/file.php/MISC249/Sauer%20-%20Numerical%20Analysis%202e.pdf)
3. [Rust, B. W. (2002). Fitting Nature's Basic Functions Part III: Exponentials, Sinusoids and Nonlinear Least Squares. Computing in Science & Engineering.](https://www.nist.gov/publications/fitting-natures-basic-functions-part-iii-exponentials-sinusoids-and-nonlinear-least)
4. [Kemmer, G. & Keller, S. (2010). Nonlinear least-squares data fitting in Excel spreadsheets. Nature Protocols 5, 267-281.](https://www.nature.com/articles/nprot.2009.182)
5. [Nonlinear Regression Modelling: A Primer with Applications and Caveats. Bulletin of Mathematical Biology (2024).](https://doi.org/10.1007/s11538-024-01274-4)
6. [An orbit determination software suite for Space Surveillance and Tracking applications. CEAS Space Journal (2024).](https://link.springer.com/article/10.1007/s12567-024-00535-1)
7. [Least Squares Optimization: From Theory to Practice. Robotics (MDPI, 2020).](https://www.mdpi.com/2218-6581/9/3/51)
8. [Nonlinear Least Squares Regression (Curve Fitter), statpages.info](https://statpages.info/nonlin.html)
9. [1944-1963: Levenberg, Marquardt, and Nonlinear Least Squares, mathematicskit documentation](https://cpoli.github.io/mathematicskit/history/optimization_breakthroughs.html)
10. [Fessler, J. Nonlinear least squares: Gauss-Newton and Levenberg-Marquardt (course notes)](https://web.eecs.umich.edu/~fessler/book/c-ox.pdf)
11. [Marquardt, D. W. (1963). An Algorithm for Least-Squares Estimation of Nonlinear Parameters. SIAM Journal on Applied Mathematics.](https://epubs.siam.org/doi/pdf/10.1137/0111030?download=true)
12. [Gauss-Newton and full Newton methods in frequency-space seismic waveform inversion. Geophysical Journal International.](https://academic.oup.com/gji/article/133/2/341/578128)
13. [A Stochastic Levenberg-Marquardt Method Using Random Models with Complexity Results. SIAM/ASA Journal on Uncertainty Quantification.](https://epubs.siam.org/doi/10.1137/20M1366253)
14. [Nonlinear Least-Squares Fitting, GSL 2.8 documentation, GNU Project](https://www.gnu.org/software/gsl/doc/html/nls.html)
15. [Initial Non-Linear Fit, NIST/SEMATECH e-Handbook of Statistical Methods](https://itl.nist.gov/div898/handbook/pmd/section6/pmd632.htm)
16. [NIST Nonlinear Regression (NLS) informational page, Statistical Reference Datasets](https://itl.nist.gov/div898/strd/nls/nls_info.shtml)
17. [Least Square Regression for Nonlinear Functions, Python Numerical Methods (UC Berkeley)](https://pythonnumericalmethods.studentorg.berkeley.edu/notebooks/chapter16.05-Least-Square-Regression-for-Nonlinear-Functions.html)
18. [Nonlinear Curve Fitting with lsqcurvefit, MATLAB & Simulink documentation](https://www.mathworks.com/help/optim/ug/nonlinear-curve-fitting-with-lsqcurvefit.html)
19. [Least Squares, NIST/SEMATECH e-Handbook of Statistical Methods (EDA section)](https://www.itl.nist.gov/div898/handbook/eda/section3/eda3653.htm)
20. [Adaptive Relative Bundle Adjustment, Microsoft Research](https://www.microsoft.com/en-us/research/publication/adaptive-relative-bundle-adjustment/)
21. [Robot localization: a comprehensive survey from classical methods to intelligent autonomy. International Journal of Intelligent Robotics and Applications (2026).](https://doi.org/10.1007/s41315-026-00528-9)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 30, 2026; Oct 15, 2026 · Edited: Sep 30, 2026; Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 数与代数 › Linear and multilinear algebra › Numerical linear algebra › Least squares and overdetermined systems

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/non-linear-least-squares

English original: https://www.edgepedia.org/non-linear-least-squares
