永发信息网

怎么对如下的数据进行最小二乘拟合

答案:2  悬赏:50  手机版
解决时间 2021-02-08 02:28
  • 提问者网友:末路
  • 2021-02-07 06:18
0.62 525.75
0.62 525.78
0.62 525.81
0.62 525.88
0.62 525.94
0.62 526.00
0.62 526.06
0.62 526.19
0.62 526.25
0.62 526.28
0.54 526.31
0.54 526.38
0.54 526.44
0.54 526.50
0.54 526.56
0.54 526.69
0.54 526.72
0.62 525.75
0.62 525.78
0.62 525.81
0.62 525.88
0.62 525.94
0.62 526.00
0.62 526.06
0.62 526.19
0.62 526.25
0.62 526.28
0.54 526.31
0.54 526.38
0.54 526.44
0.54 526.50
0.54 526.56
0.54 526.69
0.54 526.72
数据是这样的,那么怎么用最小方差无偏估计量,不用polyfit函数,进行最小二乘拟合呢?请高手指点啊
最佳答案
  • 五星知识达人网友:低血压的长颈鹿
  • 2021-02-07 06:27
不用matlab里的polyfit函数,可以用spss 之类的软件

POLYFIT Fit polynomial to data.
P = POLYFIT(X,Y,N) finds the coefficients of a polynomial P(X) of
degree N that fits the data Y best in a least-squares sense. P is a
row vector of length N+1 containing the polynomial coefficients in
descending powers, P(1)*X^N + P(2)*X^(N-1) +...+ P(N)*X + P(N+1).

[P,S] = POLYFIT(X,Y,N) returns the polynomial coefficients P and a
structure S for use with POLYVAL to obtain error estimates for
predictions. S contains fields for the triangular factor (R) from a QR
decomposition of the Vandermonde matrix of X, the degrees of freedom
(df), and the norm of the residuals (normr). If the data Y are random,
an estimate of the covariance matrix of P is (Rinv*Rinv')*normr^2/df,
where Rinv is the inverse of R.

[P,S,MU] = POLYFIT(X,Y,N) finds the coefficients of a polynomial in
XHAT = (X-MU(1))/MU(2) where MU(1) = MEAN(X) and MU(2) = STD(X). This
centering and scaling transformation improves the numerical properties
of both the polynomial and the fitting algorithm.

Warning messages result if N is >= length(X), if X has repeated, or
nearly repeated, points, or if X might need centering and scaling.

Class support for inputs X,Y:
float: double, single
全部回答
  • 1楼网友:思契十里
  • 2021-02-07 06:40
用polyfit()语句可以 polyfit(x,y,拟合次数n); x,y是你的数据,n是你要进行几次拟合,填1的话为一次也就是最小二乘法拟合 你可以这样写 x=[ 0.25 0.5 0.75 1 1.5 2 2.5 3 3.5 4 4.5 5 6 7 8 9 10 11 12 13 14 15 16]; y=[30 68 75 82 82 77 68 68 58 51 50 41 38 35 28 25 18 15 12 10 7 7 4]; p=polyfit(x,y,1); plot(x,y,'b',x,polyval(p,x),'r'); %如果作图的话,蓝线为原数据,红线为拟合数据 不知道对你有没有帮助
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯