您好,欢迎访问三七文档
当前位置:首页 > 办公文档 > 求职简历 > matlab实验11
辽宁工程技术大学上机实验报告实验名称实验十一回归分析院系理学院专业信科班级姓名学号日期20131121实验目的简述本次实验目的:1、了解回归分析基本内容2、掌握用matlab软件求解回归分析问题。实验准备你为本次实验做了哪些准备:经过看书和看ppt完成了此次实验。实验进度本次共有6个练习,完成6个。实验总结日本次实验的收获、体会、经验、问题和教训:通过本次实验学会了有关回归分析的有关知识,怎么求线性与非线性回归模型,知道了怎么找β系数和置信区间,知道了有关回归分析有关的matlab命令,在实验的过程中遇到了很多的难题,比如怎么观察模型是不是线性的,比如怎么找到最合适的模型,这时通过看书和认真思考学会了怎么做。本次实验收获了很多,知道了自己的不足,以后还需要勤加训练!教师评语成绩1、考察温度x对产量y的影响,测得下列10组数据:温度(℃)20253035404550556065产量(kg)13.215.116.417.117.918.719.621.222.524.3求y关于x的线性回归方程,检验回归效果是否显著,并预测x=42℃时产量的估值及预测区间(置信度95%).x=[20253035404550556065]';X=[ones(10,1)x];y=[13.215.116.417.117.918.719.621.222.524.3]’;corrcoef(x,y)ans=1.00000.99100.99101.0000[b,bint,r,rint,stats]=regress(y,X)b=9.12120.2230bint=8.021110.22140.19850.2476stats=0.9821439.83110.00000.2333置信区间[8.0211,10.2214]置信区间[0.1985,0.2476]r2=0.9821F=439.8311p=0.0000p0.05回归模型:y=9.1212+0.2230x成立r2=0.9821接近1回归方程显著X=42时y=18.48722、某零件上有一段曲线,为了在程序控制机床上加工这一零件,需要求这段曲线的解析表达式,在曲线横坐标xi处测得纵坐标yi共11对数据如下:xi02468101214161820yi0.62.04.47.511.817.123.331.239.649.761.7求这段曲线的纵坐标y关于横坐标x的二次多项式回归方程.(并画出图形)x=[02468101214161820];y=[0.62.04.47.511.817.123.331.239.649.761.7];[p,S]=polyfit(x,y,2)p=0.14030.19711.0105S=R:[3x3double]df:8normr:1.1097Y=polyconf(x,y,S)回归模型:y=0.1403x2+0.1971x+1.0105X=[ones(11,1)x'(x.^2)']r=-0.38180.40300.58790.1727-0.1424-0.4576-0.6727-0.1879-0.00300.6818rint=-1.28580.5221-0.56751.3736-0.36391.5397-0.92931.2748-1.26320.9783-1.51230.5972-1.61790.2725-1.25630.8806-1.03521.0291-0.07631.4399X=100124141616361864110100112144114196116256118324120400[b,bint,r,rint,stats]=regress(y',X);Y=polyconf(p,x,S)plot(x,y,'k+',x,Y,'r')Y=1.01051.96604.04417.244911.568317.014223.582831.274040.087850.024261.0832024681012141618200102030405060703、在研究化学动力学反应过程中,建立了一个反应速度和反应物含量的数学模型,形式为34231253211xxxxxy其中51,,是未知参数,321,,xxx是三种反应物(氢,n戊烷,异构戊烷)的含量,y是反应速度.今测得一组数据如下表,试由此确定参数51,,,并给出置信区间.51,,的参考值为(1,0.05,0.02,0.1,2).序号反应速度y氢x1n戊烷x2异构戊烷x318.554703001023.79285801034.8247030012040.024708012052.754708010614.391001901072.54100806584.3547019065913.0010030054108.50100300120110.05100801201211.3228530010133.13285190120解:x1=[470285470470470100100470100100100285285]';x2=[3008030080801908019030030080300190]';x3=[1010120120101065655412012010120]';x=[x1x2x3];y=[8.553.794.820.022.7514.392.544.3513.008.500.0511.323.13]';f=@(beta,x)(beta(1).*x(:,2)-(1/beta(5)).*x(:,3)).*((1+beta(2).*x(:,1)+beta(3).*x(:,2)+beta(4).*x(:,3))).^(-1);beta0=[10.050.020.12]';opt=optimset('TolFun',1e-3,'TolX',1e-3);[beta,bint]=nlinfit(x,y,f,beta0,opt)beta=1.12920.05660.03570.10181.3160得到beta的拟合值及95%的置信区间4、混凝土的抗压强度随养护时间的延长而增加,现将一批混凝土作成12个试块,记录了养护日期x(日)及抗压强度y(kg/cm2)的数据:养护时间x234579121417212856抗压强度y354247535965687376828699试求xbaylnˆ型回归方程.对将要拟合的非线性模型xbaylnˆ,建立M文件volum.m如下functionyhat=volum(beta,x)yhat=beta(1)+beta(2)*log(x);即得回规模型为xyln5287.190053.21ˆbint=0.1254-0.1508-0.08230.03990.12020.07020.00080.3200-0.02820.12700.0891-0.1619-0.2862x=[234579121417212856];y=[354247535965687376828699];beta0=[51]';[beta,r,J]=nlinfit(x',y','volum',beta0);beta=21.005319.52870102030405060304050607080901005、下表给出了某工厂产品的生产批量与单位成本(元)的数据,从散点图,可以明显的发现,生产批量在500以内时,单位成本对生产批量服从一种线性关系,生产批量超过500时服从另一种线性关系,此时单位成本明显下降。希望你构造一个合适的回归模型全面地描述生产批量与单位成本的关系。生产批量650340400800300600720480440540750单位成本2.484.454.521.384.652.962.184.044.203.101.50记生产批量x1500时,单位成本为y1,生产批量x2500时,单位成本为y2。为了大致地分析y与x的关系,首先利用表中表中数据分别作出y1对x1和y2对x2的散点图。由图像可知两段程线性关系,所以做以下程序:两段直线,x小于500时:x1=[340,400,300,480,440]';y1=[4.45,4.52,4.65,4.04,4.20]';X=[ones(size(x1))x1];[b,bint,r,rint,stats]=regress(y1,X)b=5.5863-0.0031bint=4.57436.5983-0.0056-0.0006stats=0.833214.98680.03050.0136stepwise(X,y1,[1,2])回归模型:y=5.5863-0.0031x-1012x1015X1X2CoefficientswithErrorBarsCoeff.t-statp-val4.97329e+0140.83370.4656-0.00339944-3.74390.03331-1012ModelHistoryRMSE20.819355R6.80359F0.0767782prcoplot(r,rint)r=-0.08310.1728-0.0070-0.0594-0.0233rint=-0.40610.23990.05530.2902-0.29510.2811-0.32850.2097-0.39810.35140.511.522.533.544.555.5-0.4-0.3-0.2-0.100.10.20.3ResidualCaseOrderPlotResidualsCaseNumber从结果可以看出,应将第二个点去掉后再进行拟合;两段直线,x大于500时:x2=[650,800,600,720,540,750]';y2=[2.48,1.38,2.96,2.18,3.10,1.50]';X=[ones(size(x2))x2];[b,bint,r,rint,stats]=regress(y2,X)b=7.1158-0.0072bint=5.43168.8000-0.0096-0.0047stats=0.942065.01530.00130.0377回归模型:y=7.1158-0.0072xstepwise(X,y2,[1,2])r=0.0222-0.00280.14390.2239-0.1460-0.2411rint=-0.53980.5843-0.44940.4437-0.32720.6151-0.19910.6469-0.48740.1953-0.60150.1192-6-4-20246x1014X1X2CoefficientswithErrorBarsCoeff.t-statp-val2.49747e+0130.12600.9058-0.00715102-7.93490.00141-1012ModelHistoryRMSE20.941471R32.178F0.0034257prcoplot(r,rint)123456-0.6-0.4-0.200.20.40.6ResidualCaseOrderPlotResidualsCaseNumber由图可知,数据无异常点。若直接考虑全组数据,对整个11组数据直接拟合。整组数据:x1=[650,340,400,800,300,600,720,480,440,540,750]';y1=[2.48,4.45,4.52,1.38,4.65,2.96,2.18,4.04,4.20,3.10,1.50]';X=[ones(size(x1))x1];[b,bint,r,rint,stats]=regress(y1,X)b=7.0779-0.0070bint=6.48457.6713-0.0081-0.0060stats=0.9631234.89360.00000.0612回归模型:y=7.10779-0.0070xstepwise(X,y1,[1,2])rin
本文标题:matlab实验11
链接地址:https://www.777doc.com/doc-5609520 .html