注册地址 登录
数学建模社区-数学中国 返回首页

大智若愚的个人空间 http://www.madio.net/?588208 [收藏] [复制] [分享] [RSS]

日志

matlab和统计分析有关的

已有 391 次阅读2013-1-24 10:00

【多项式f(x)=a(1)*X^m+…+a(m)*X+a(m+1)拟合】
x=[];
y=[];
A=polyfit(x,y,m)  %m为猜测的拟合多项式的系数
z=polyval(A,x);
plot(x,y,'+',x,z)  %画出拟合曲线,描出已知点

【非线性拟合lsqcurvefit】
建立M文件:
function f=curvefun1(x,xdata)
f=x(1)+x(2)*exp(x(3)*xdata)
%x(1)=a;x(2)=b;x(3)=k;

主程序:
xdata=[];或者xmin:n:xmax; %已知x的数据
ydata=[];  %已知y的数据
x0=[a0,b0,k0]; %a0,b0,k0分别为迭代初始值
x=lsqcurvefit ('curvefun1',x0,xdata,ydata)
f=curvefun1(x,xdata) 

【非线性拟合lsqnonlin】
建立M文件:
function f=curvefun2(x)
xdata=[];或者xmin:n:xmax; %已知x的数据
ydata=[];  %已知y的数据
f=x(1)+x(2)*exp(x(3)*xdata)- ydata
%x(1)=a;x(2)=b;x(3)=k;

【求曲线交点】
[x,y]=solve('y=-0.0259*x^2+0.4631*x+0.0315','y=0.2*x^2-5.5059*x+38.9763')

【求积分】
int(P)           对表达式P进行不定积分.
int(P,v)          以v为积分变量对P进行不定积分.
int(P,v,a,b)       以v为积分变量,以a为下限,b为上限对P进行定积分.
int('x*log(1+x)',0,1)   得
ans = 1/4  


主程序:
x0=[a0,b0,k0]; %a0,b0,k0分别为迭代初始值
x=lsqnonlin('curvefun2',x0)
f=curvefun2(x)

【拟合判断】
SSE (趋向0最好)-- The sum of squares due to error. This statistic measures the deviation of the responses from the fitted values of the responses. A value closer to 0 indicates a better fit. 
R-square(趋向1最好) -- The coefficient of multiple determination. This statistic measures how successful the fit is in explaining the variation of the data. A value closer to 1 indicates a better fit. 
Adjusted R-square(趋向1最好) -- The degree of freedom adjusted R-square. A value closer to 1 indicates a better fit. It is generally the best indicator of the fit quality when you add additional coefficients to your model. 
RMSE(趋向0最好) -- The root mean squared error. A value closer to 0 indicates a better fit.


路过

雷人

握手

鲜花

鸡蛋

评论 (0 个评论)

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 注册地址

qq
收缩
  • 电话咨询

  • 04714969085

关于我们| 联系我们| 诚征英才| 对外合作| 产品服务| QQ

手机版|Archiver| |繁體中文 手机客户端  

蒙公网安备 15010502000194号

Powered by Discuz! X2.5   © 2001-2013 数学建模网-数学中国 ( 蒙ICP备14002410号-3 蒙BBS备-0002号 )     论坛法律顾问:王兆丰

GMT+8, 2025-8-2 13:31 , Processed in 0.220283 second(s), 27 queries .

回顶部