一种数学程序,通过最小化点到曲线偏移量(“残差”)平方和,找到给定点集的最佳拟合曲线。偏移量平方和代替偏移量绝对值,因为这样可以将残差视为连续可微量。然而,由于使用了偏移量的平方,离群点可能对拟合产生过度的影响,这在某些情况下可能是期望的,而在另一些情况下则可能是不期望的,具体取决于手头的问题。
在实践中,几乎总是最小化与直线(多项式、曲面、超平面等)的垂直偏移,而不是垂直偏移。这为自变量
提供了一个拟合函数,用于估计给定
的
值(这通常是实验者想要的),使得可以简单地纳入数据点沿
轴和
轴的不确定性,并且与基于 垂直偏移 的拟合相比,为拟合参数提供了更简单的解析形式。此外,当使用垂直距离之和时,拟合技术可以很容易地从最佳拟合直线推广到最佳拟合多项式。在任何情况下,对于合理数量的噪声数据点,垂直拟合和垂直拟合之间的差异非常小。
线性最小二乘拟合技术是 线性回归 最简单和最常用的形式,它为找到穿过一组点的最佳拟合直线问题提供了解决方案。事实上,如果被绘制图形的两个量之间的函数关系在加法或乘法常数范围内已知,通常的做法是以某种方式转换数据,使得结果线是直线,例如在分析摆的周期
与其长度
的函数关系时,绘制
与
而不是
与
。因此,指数、对数和 幂 律的标准形式通常被显式计算出来。线性最小二乘拟合的公式由高斯和勒让德独立推导出来。
对于多个未知参数的 非线性最小二乘拟合,可以将线性最小二乘拟合迭代应用于函数的线性化形式,直到实现收敛。然而,通常也可以在开始时线性化非线性函数,并且仍然可以使用线性方法来确定拟合参数,而无需诉诸迭代程序。这种方法通常违反了误差分布是 正态 分布的隐含假设,但通常仍然可以使用正态方程、伪逆 等给出可接受的结果。根据拟合的类型和选择的初始参数,非线性拟合可能具有良好或较差的收敛特性。如果给出了点的不确定性(在最一般的情况下是误差椭圆),则可以对点进行不同的加权,以便为高质量的点赋予更高的权重。
垂直最小二乘拟合通过找到一组
个数据点的垂直偏差
的平方和来进行
![R^2=sum[y_i-f(x_i,a_1,a_2,...,a_n)]^2](/images/equations/LeastSquaresFitting/NumberedEquation1.svg) |
(1)
|
来自函数
。请注意,此过程不会最小化与直线的实际偏差(这将垂直于给定函数测量)。此外,虽然距离的未平方和可能看起来是更合适的最小化量,但使用绝对值会导致不连续的导数,无法进行解析处理。因此,将每个点的平方偏差相加,然后最小化得到的残差以找到最佳拟合线。此过程导致离群点被赋予不成比例的权重。
为最小值的条件是
![(partial(R^2))/(partiala_i)=0](/images/equations/LeastSquaresFitting/NumberedEquation2.svg) |
(2)
|
对于
, ...,
。 对于线性拟合,
![f(a,b)=a+bx,](/images/equations/LeastSquaresFitting/NumberedEquation3.svg) |
(3)
|
因此
![R^2(a,b)=sum_(i=1)^n[y_i-(a+bx_i)]^2](/images/equations/LeastSquaresFitting/NumberedEquation4.svg) |
(4)
|
![(partial(R^2))/(partiala)=-2sum_(i=1)^n[y_i-(a+bx_i)]=0](/images/equations/LeastSquaresFitting/NumberedEquation5.svg) |
(5)
|
![(partial(R^2))/(partialb)=-2sum_(i=1)^n[y_i-(a+bx_i)]x_i=0.](/images/equations/LeastSquaresFitting/NumberedEquation6.svg) |
(6)
|
这些导出以下方程
以 矩阵 形式,
![[n sum_(i=1)^(n)x_i; sum_(i=1)^(n)x_i sum_(i=1)^(n)x_i^2][a; b]=[sum_(i=1)^(n)y_i; sum_(i=1)^(n)x_iy_i],](/images/equations/LeastSquaresFitting/NumberedEquation7.svg) |
(9)
|
因此
![[a; b]=[n sum_(i=1)^(n)x_i; sum_(i=1)^(n)x_i sum_(i=1)^(n)x_i^2]^(-1)[sum_(i=1)^(n)y_i; sum_(i=1)^(n)x_iy_i].](/images/equations/LeastSquaresFitting/NumberedEquation8.svg) |
(10)
|
矩阵 的逆是
![[a; b]=1/(nsum_(i=1)^(n)x_i^2-(sum_(i=1)^(n)x_i)^2)[sum_(i=1)^(n)y_isum_(i=1)^(n)x_i^2-sum_(i=1)^(n)x_isum_(i=1)^(n)x_iy_i; nsum_(i=1)^(n)x_iy_i-sum_(i=1)^(n)x_isum_(i=1)^(n)y_i],](/images/equations/LeastSquaresFitting/NumberedEquation9.svg) |
(11)
|
因此
(Kenney 和 Keeping 1962)。 这些可以通过定义平方和以更简单的形式重写
也可以写成
这里,
是 协方差,
和
是方差。 请注意,量
和
也可以解释为 点积
用平方和表示,回归系数
由下式给出
![b=(cov(x,y))/(sigma_x^2)=(ss_(xy))/(ss_(xx)),](/images/equations/LeastSquaresFitting/NumberedEquation10.svg) |
(27)
|
并且
用
表示,使用 (◇) 为
![a=y^_-bx^_.](/images/equations/LeastSquaresFitting/NumberedEquation11.svg) |
(28)
|
拟合的整体质量然后用称为 相关系数 的量来参数化,其定义为
![r^2=(ss_(xy)^2)/(ss_(xx)ss_(yy)),](/images/equations/LeastSquaresFitting/NumberedEquation12.svg) |
(29)
|
这给出了回归解释的
的比例。
设
是 x 坐标为
的最佳拟合直线的垂直坐标,因此
![y^^_i=a+bx_i,](/images/equations/LeastSquaresFitting/NumberedEquation13.svg) |
(30)
|
那么实际垂直点
和拟合点之间的误差由下式给出
![e_i=y_i-y^^_i.](/images/equations/LeastSquaresFitting/NumberedEquation14.svg) |
(31)
|
现在定义
作为
方差的估计量,
![s^2=sum_(i=1)^n(e_i^2)/(n-2).](/images/equations/LeastSquaresFitting/NumberedEquation15.svg) |
(32)
|
那么
可以由下式给出
![s=sqrt((ss_(yy)-bss_(xy))/(n-2))=sqrt((ss_(yy)-(ss_(xy)^2)/(ss_(xx)))/(n-2))](/images/equations/LeastSquaresFitting/NumberedEquation16.svg) |
(33)
|
(Acton 1966, pp. 32-35; Gonick 和 Smith 1993, pp. 202-204)。
和
的标准误差是
另请参阅
ANOVA,
相关系数,
插值,
最小二乘拟合--指数,
最小二乘拟合--对数,
最小二乘拟合--垂直偏移,
最小二乘拟合--多项式,
最小二乘拟合--幂律,
MANOVA,
矩阵 1-逆,
Moore-Penrose 矩阵逆,
非线性最小二乘拟合,
伪逆,
回归系数,
残差,
样条 在 MathWorld 课堂中探索此主题
使用 Wolfram|Alpha 探索
参考文献
Acton, F. S. Analysis of Straight-Line Data. New York: Dover, 1966.Bevington, P. R. Data Reduction and Error Analysis for the Physical Sciences. New York: McGraw-Hill, 1969.Chatterjee, S.; Hadi, A.; and Price, B. "Simple Linear Regression." Ch. 2 in Regression Analysis by Example, 3rd ed. New York: Wiley, pp. 21-50, 2000.Edwards, A. L. "The Regression Line
on
." Ch. 3 in An Introduction to Linear Regression and Correlation. San Francisco, CA: W. H. Freeman, pp. 20-32, 1976.Farebrother, R. W. Fitting Linear Relationships: A History of the Calculus of Observations 1750-1900. New York: Springer-Verlag, 1999.Gauss, C. F. "Theoria combinationis obsevationum erroribus minimis obnoxiae." Werke, Vol. 4. Göttingen, Germany: p. 1, 1823.Gonick, L. and Smith, W. The Cartoon Guide to Statistics. New York: Harper Perennial, 1993.Kenney, J. F. and Keeping, E. S. "Linear Regression, Simple Correlation, and Contingency." Ch. 8 in Mathematics of Statistics, Pt. 2, 2nd ed. Princeton, NJ: Van Nostrand, pp. 199-237, 1951.Kenney, J. F. and Keeping, E. S. "Linear Regression and Correlation." Ch. 15 in Mathematics of Statistics, Pt. 1, 3rd ed. Princeton, NJ: Van Nostrand, pp. 252-285, 1962.Lancaster, P. and Šalkauskas, K. Curve and Surface Fitting: An Introduction. London: Academic Press, 1986.Laplace, P. S. "Des méthodes analytiques du Calcul des Probabilités." Ch. 4 in Théorie analytique des probabilités, Livre 2, 3rd ed. Paris: Courcier, 1820.Lawson, C. and Hanson, R. Solving Least Squares Problems. Englewood Cliffs, NJ: Prentice-Hall, 1974.Ledvij, M. "Curve Fitting Made Easy." Industrial Physicist 9, 24-27, Apr./May 2003.Nash, J. C. Compact Numerical Methods for Computers: Linear Algebra and Function Minimisation, 2nd ed. Bristol, England: Adam Hilger, pp. 21-24, 1990.Press, W. H.; Flannery, B. P.; Teukolsky, S. A.; and Vetterling, W. T. "Fitting Data to a Straight Line" "Straight-Line Data with Errors in Both Coordinates," and "General Linear Least Squares." §15.2, 15.3, and 15.4 in Numerical Recipes in FORTRAN: The Art of Scientific Computing, 2nd ed. Cambridge, England: Cambridge University Press, pp. 655-675, 1992.Whittaker, E. T. and Robinson, G. "The Method of Least Squares." Ch. 9 in The Calculus of Observations: A Treatise on Numerical Mathematics, 4th ed. New York: Dover, pp. 209-, 1967.York, D. "Least-Square Fitting of a Straight Line." Canad. J. Phys. 44, 1079-1086, 1966.在 Wolfram|Alpha 上引用
最小二乘拟合
请按如下方式引用
Weisstein, Eric W. "Least Squares Fitting." 来自 MathWorld--Wolfram Web 资源。 https://mathworld.net.cn/LeastSquaresFitting.html
主题分类