主題
Search

最小二乘擬合


LeastSquaresFitting

一種數學程式,透過最小化點到曲線偏移量(“殘差”)平方和,找到給定點集的最佳擬合曲線。偏移量平方和代替偏移量絕對值,因為這樣可以將殘差視為連續可微量。然而,由於使用了偏移量的平方,離群點可能對擬合產生過度的影響,這在某些情況下可能是期望的,而在另一些情況下則可能是不期望的,具體取決於手頭的問題。

LeastSquaresOffsets

在實踐中,幾乎總是最小化與直線(多項式、曲面、超平面等)的垂直偏移,而不是垂直偏移。這為自變數 X 提供了一個擬合函式,用於估計給定 xy 值(這通常是實驗者想要的),使得可以簡單地納入資料點沿 x 軸和 y 軸的不確定性,並且與基於 垂直偏移 的擬合相比,為擬合引數提供了更簡單的解析形式。此外,當使用垂直距離之和時,擬合技術可以很容易地從最佳擬合直線推廣到最佳擬合多項式。在任何情況下,對於合理數量的噪聲資料點,垂直擬合和垂直擬合之間的差異非常小。

線性最小二乘擬合技術是 線性迴歸 最簡單和最常用的形式,它為找到穿過一組點的最佳擬合直線問題提供瞭解決方案。事實上,如果被繪製圖形的兩個量之間的函式關係在加法或乘法常數範圍內已知,通常的做法是以某種方式轉換資料,使得結果線直線,例如在分析擺的週期 T 與其長度 l 的函式關係時,繪製 Tsqrt(l) 而不是 Tl。因此,指數對數 律的標準形式通常被顯式計算出來。線性最小二乘擬合的公式由高斯和勒讓德獨立推匯出來。

對於多個未知引數的 非線性最小二乘擬合,可以將線性最小二乘擬合迭代應用於函式的線性化形式,直到實現收斂。然而,通常也可以在開始時線性化非線性函式,並且仍然可以使用線性方法來確定擬合引數,而無需訴諸迭代程式。這種方法通常違反了誤差分佈是 正態 分佈的隱含假設,但通常仍然可以使用正態方程、偽逆 等給出可接受的結果。根據擬合的型別和選擇的初始引數,非線性擬合可能具有良好或較差的收斂特性。如果給出了點的不確定性(在最一般的情況下是誤差橢圓),則可以對點進行不同的加權,以便為高質量的點賦予更高的權重。

垂直最小二乘擬合通過找到一組 n 個數據點的垂直偏差 R^2 的平方和來進行

 R^2=sum[y_i-f(x_i,a_1,a_2,...,a_n)]^2
(1)

來自函式 f。請注意,此過程不會最小化與直線的實際偏差(這將垂直於給定函式測量)。此外,雖然距離的未平方和可能看起來是更合適的最小化量,但使用絕對值會導致不連續的導數,無法進行解析處理。因此,將每個點的平方偏差相加,然後最小化得到的殘差以找到最佳擬合線。此過程導致離群點被賦予不成比例的權重。

R^2 為最小值的條件是

 (partial(R^2))/(partiala_i)=0
(2)

對於 i=1, ..., n。 對於線性擬合,

 f(a,b)=a+bx,
(3)

因此

 R^2(a,b)=sum_(i=1)^n[y_i-(a+bx_i)]^2
(4)
 (partial(R^2))/(partiala)=-2sum_(i=1)^n[y_i-(a+bx_i)]=0
(5)
 (partial(R^2))/(partialb)=-2sum_(i=1)^n[y_i-(a+bx_i)]x_i=0.
(6)

這些匯出以下方程

na+bsum_(i=1)^(n)x_i=sum_(i=1)^(n)y_i
(7)
asum_(i=1)^(n)x_i+bsum_(i=1)^(n)x_i^2=sum_(i=1)^(n)x_iy_i.
(8)

矩陣 形式,

 [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],
(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].
(10)

2×2 矩陣 的逆是

 [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],
(11)

因此

a=(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_i^2-(sum_(i=1)^(n)x_i)^2)
(12)
=(y^_(sum_(i=1)^(n)x_i^2)-x^_sum_(i=1)^(n)x_iy_i)/(sum_(i=1)^(n)x_i^2-nx^_^2)
(13)
b=(nsum_(i=1)^(n)x_iy_i-sum_(i=1)^(n)x_isum_(i=1)^(n)y_i)/(nsum_(i=1)^(n)x_i^2-(sum_(i=1)^(n)x_i)^2)
(14)
=((sum_(i=1)^(n)x_iy_i)-nx^_y^_)/(sum_(i=1)^(n)x_i^2-nx^_^2)
(15)

(Kenney 和 Keeping 1962)。 這些可以透過定義平方和以更簡單的形式重寫

ss_(xx)=sum_(i=1)^(n)(x_i-x^_)^2
(16)
=(sum_(i=1)^(n)x_i^2)-nx^_^2
(17)
ss_(yy)=sum_(i=1)^(n)(y_i-y^_)^2
(18)
=(sum_(i=1)^(n)y_i^2)-ny^_^2
(19)
ss_(xy)=sum_(i=1)^(n)(x_i-x^_)(y_i-y^_)
(20)
=(sum_(i=1)^(n)x_iy_i)-nx^_y^_,
(21)

也可以寫成

sigma_x^2=(ss_(xx))/n
(22)
sigma_y^2=(ss_(yy))/n
(23)
cov(x,y)=(ss_(xy))/n.
(24)

這裡,cov(x,y)協方差sigma_x^2sigma_y^2 是方差。 請注意,量 sum_(i=1)^(n)x_iy_isum_(i=1)^(n)x_i^2 也可以解釋為 點積

sum_(i=1)^(n)x_i^2=x·x
(25)
sum_(i=1)^(n)x_iy_i=x·y.
(26)

用平方和表示,迴歸係數 b 由下式給出

 b=(cov(x,y))/(sigma_x^2)=(ss_(xy))/(ss_(xx)),
(27)

並且 ab 表示,使用 (◇) 為

 a=y^_-bx^_.
(28)

擬合的整體質量然後用稱為 相關係數 的量來引數化,其定義為

 r^2=(ss_(xy)^2)/(ss_(xx)ss_(yy)),
(29)

這給出了迴歸解釋的 ss_(yy) 的比例。

y^^_i 是 x 座標為 x_i 的最佳擬合直線的垂直座標,因此

 y^^_i=a+bx_i,
(30)

那麼實際垂直點 y_i 和擬合點之間的誤差由下式給出

 e_i=y_i-y^^_i.
(31)

現在定義 s^2 作為 e_i 方差的估計量,

 s^2=sum_(i=1)^n(e_i^2)/(n-2).
(32)

那麼 s 可以由下式給出

 s=sqrt((ss_(yy)-bss_(xy))/(n-2))=sqrt((ss_(yy)-(ss_(xy)^2)/(ss_(xx)))/(n-2))
(33)

(Acton 1966, pp. 32-35; Gonick 和 Smith 1993, pp. 202-204)。

ab 的標準誤差是

SE(a)=ssqrt(1/n+(x^_^2)/(ss_(xx)))
(34)
SE(b)=s/(sqrt(ss_(xx))).
(35)

另請參閱

ANOVA, 相關係數, 插值, 最小二乘擬合--指數, 最小二乘擬合--對數, 最小二乘擬合--垂直偏移, 最小二乘擬合--多項式, 最小二乘擬合--冪律, MANOVA, 矩陣 1-逆, Moore-Penrose 矩陣逆, 非線性最小二乘擬合, 偽逆, 迴歸係數, 殘差, 樣條 在 課堂中探索此主題

使用 探索

參考文獻

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 Y on X." 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.

在 上引用

最小二乘擬合

請按如下方式引用

Weisstein, Eric W. "Least Squares Fitting." 來自 Web 資源。 https://mathworld.tw/LeastSquaresFitting.html

主題分類