日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > 数据库 >内容正文

数据库

mysql 多项式_多项式拟合和最小二乘问题

發(fā)布時(shí)間:2025/3/19 数据库 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql 多项式_多项式拟合和最小二乘问题 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

背景知識(shí)

The method of least squares is a standard approach in regression analysis to the approximate solution of overdetermined systems, i.e., sets of equations in which there are more equations than unknowns. "Least squares" means that the overall solution minimizes the sum of the squares of the errors made in the results of every single equation.

多項(xiàng)式擬合

The first clear and concise exposition of the method of least squares was published by Legendre in 1805.[5] The technique is described as an algebraic procedure for fitting linear equations to data and Legendre demonstrates the new method by analyzing the same data as Laplace for the shape of the earth. The value of Legendre's method of least squares was immediately recognized by leading astronomers and geodesists of the time.

實(shí)驗(yàn)一

%%給定數(shù)據(jù)對(duì),(x0,y0)

x0=0:0.1:1;

y0=[-.447,1.978,3.11,5.25,5.02,4.66,4.01,4.58,3.45,5.35,9.22];

%%求擬合多項(xiàng)式

n=3;%假設(shè)數(shù)據(jù)對(duì)(x0,y0)一共有m對(duì),則通常情況下,應(yīng)當(dāng)保證n

%%求得x0,y0數(shù)組所給數(shù)據(jù)的n階擬合多項(xiàng)式系數(shù)向量p,為了保證較好的擬合效果,多項(xiàng)式的階數(shù)要取得適當(dāng),過低,殘差較大;過高,擬合模型將包含噪聲影響。

P=polyfit(x0,y0,n)

%圖示擬合情況

xx=0:0.01:1;

yy=polyval(P,xx);

%?y?=?polyval(p,x)?returns?the?value?of?a?polynomial?of?degree?n?evaluated

%?at?x.?The?input?argument?p?is?a?vector?of?length?n+1?whose?elements?are

%?the?coefficients?in?descending?powers?of?the?polynomial?to?be?evaluated.

%

%?y?=?p1xn?+?p2xn–1?+?…?+?pnx?+?pn+1

plot(xx,yy,'-b',x0,y0,'.r','MarkerSize',20)

legend('擬合曲線','原始數(shù)據(jù)','Location','SouthEast')

xlabel('x')

最小二乘

Least squares problems fall into two categories: linear or ordinary least squares and non-linear least squares, depending on whether or not the residuals are linear in all unknowns. The linear least-squares problem occurs in statistical regression analysis; it has a closed-form solution. The non-linear problem is usually solved by iterative refinement; at each iteration the system is approximated by a linear one, and thus the core calculation is similar in both cases.

實(shí)驗(yàn)二

%%給定自變量x數(shù)據(jù)組

x0=(0:0.1:1);

%%給定自變量y數(shù)據(jù)組

y0=[-.447,1.978,3.11,5.25,5.02,4.66,4.01,4.68,4.45,5.35,9.22]';

m=length(x0);

n=3;

%多項(xiàng)式階數(shù)

%%初始化數(shù)據(jù)陣X

X=zeros(m,n+1);

%%將X設(shè)置成各列等比的形式

for?k=1:n

X(:,n-k+1)=(x0.^k);

end

X(:,n+1)=ones(m,1);

%%利用最小二乘原理求解多項(xiàng)式系數(shù)

aT=(X\y0)'

aT =

51.9713 ?-80.2234 ? 37.7844 ? -0.8078

總結(jié)

以上是生活随笔為你收集整理的mysql 多项式_多项式拟合和最小二乘问题的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。