数学建模实验四.docx
《数学建模实验四.docx》由会员分享,可在线阅读,更多相关《数学建模实验四.docx(21页珍藏版)》请在冰豆网上搜索。
数学建模实验四
实验4实验报告
2013326601054夏海浜13信科1班
完成教材(2013高教版)实验;
P136T2
程序:
clear
P1=binopdf(45,100,0.5)
p=binopdf(44,100,0.5);
P2=P1-p
x=0:
100;
P3=binocdf(x,100,0.5);
P4=binopdf(x,100,0.5);
subplot(2,1,1)
plot(x,P4,'*')
title('概率累积')
subplot(2,1,2)
plot(x,P4,'+')
title('概率密度')
图:
运行结果:
P1=
0.0485
P2=
0.0095
P140T1
程序:
例1:
clear;
clc;
x=[0.236,0.257,0.258;
0.238,0.253,0.264;
0.248,0.255,0.259;
0.245,0.254,0.267;
0.243,0.261,0.262];
group=[1,1,1,1,1];
p=anova1(x)
图:
p=
1.3431e-05
例2:
clear;
clc;
x=[58.2,56.2,65.3;
52.6,41.2,60.8;
49.1,54.1,51.6;
42.8,50.5,48.4;
60.1,70.9,39.2;
58.3,73.2,40.7;
75.8,58.2,48.7;
71.5,51.0,41.4];
p=anova2(x,2)
p=
0.00350.02600.0001
P145T1
程序:
x1=[3.55.35.14.26.06.85.53.17.24.58.06.56.53.76.27.04.55.95.64.83.9];
x2=[920183113253054725233539217402333273415];
x3=[6.16.47.47.55.96.04.05.88.35.07.67.05.04.05.57.03.54.94.38.05.8];
Y=[11.113.412.913.812.513.013.610.017.612.714.414.714.211.211.416.012.013.512.315.111.7]';
subplot(1,3,1),plot(x1,Y,'*'),title('Y与x1的散点图')
subplot(1,3,2),plot(x2,Y,'+'),title('Y与x2的散点图')
subplot(1,3,3),plot(x3,Y,'o'),title('Y与x3的散点图')
散点图:
b=
6.2914
0.2954
0.1072
0.4450
bint=
5.29947.2833
0.12370.4671
0.08720.1271
0.30020.5899
r=
0.0953
0.5511
-0.1205
-0.3925
0.4171
-0.6499
0.6883
-0.3243
0.4504
0.1746
-0.1020
-0.3781
-0.4168
-0.2153
0.0792
0.2383
0.3565
-0.2519
-0.4532
0.1862
0.0676
rint=
-0.68580.8765
-0.24431.3466
-0.92940.6884
-1.11960.3345
-0.35111.1853
-1.39580.0961
-0.01621.3929
-1.05660.4081
-0.23331.1340
-0.65391.0030
-0.80390.5998
-1.18200.4257
-1.17450.3410
-0.99240.5617
-0.64520.8035
-0.55561.0321
-0.39881.1118
-1.06180.5579
-1.23170.3253
-0.55990.9322
-0.75300.8882
stats=
0.9564124.44530.00000.1624
从两种残差图都可以看到残差的大部分分布在零的附近,因此还是比较好的,去掉4,12,19这三个样本点后残差更加接近原点,重新拟合得到回归模型为
且回归系数的置信区间更小,均不包括原点,统计变量stats包含的三个检验统计量:
相关系数的平方R方,假设检验统计量F,概率P分别为0.9564,124.4453,0.0000,比较可知R,F均增加,说明模型得到改进。
P149T2
程序:
A=[3.5,5.3,5.1,5.8,4.2,6.0,6.8,5.5,3.1,7.2,4.5,4.9,8.0,6.5,6.5,3.7,6.2,7.0,4.0,4.5,5.9,5.6,4.8,3.9;9,20,18,33,31,13,25,30,5,47,25,11,23,35,39,21,7,40,35,23,33,27,34,15;6.1,6.4,7.4,6.7,7.5,5.9,6.0,4.0,5.8,8.3,5.0,6.4,7.6,7.0,5.0,4.0,5.5,7.0,6.0,3.5,4.9,4.3,8.0,5.8]';
Y=[11.113.412.915.613.812.513.013.610.017.612.710.614.414.714.211.211.416.012.712.013.512.315.111.7]';
x1=A(:
1);
x2=A(:
2);
x3=A(:
3);
x4=x1.*x2;
x5=x1.*x3;
x6=x2.*x3;
X=[A,x4,x5,x6];
stepwise(X,Y)
图:
T3
程序:
x1=[1.376,1.375,1.387,1.401,1.412,1.428,1.445,1.477]'
x2=[0.450,0.475,0.485,0.500,0.535,0.545,0.550,0.575]'
x3=[2.170,2.554,2.676,2.713,2.823,3.088,3.122,3.262]'
x4=[0.8922,1.1610,0.5346,0.9589,1.0239,1.0499,1.1065,1.1387]'
x=[x1,x2,x3,x4]
R=corrcoef(x)
[V,D]=eig(R)
运行结果:
x1=
1.3760
1.3750
1.3870
1.4010
1.4120
1.4280
1.4450
1.4770
x2=
0.4500
0.4750
0.4850
0.5000
0.5350
0.5450
0.5500
0.5750
x3=
2.1700
2.5540
2.6760
2.7130
2.8230
3.0880
3.1220
3.2620
x4=
0.8922
1.1610
0.5346
0.9589
1.0239
1.0499
1.1065
1.1387
x=
1.37600.45002.17000.8922
1.37500.47502.55401.1610
1.38700.48502.67600.5346
1.40100.50002.71300.9589
1.41200.53502.82301.0239
1.42800.54503.08801.0499
1.44500.55003.12201.1065
1.47700.57503.26201.1387
R=
1.00000.94830.91190.4613
0.94831.00000.96830.4747
0.91190.96831.00000.4036
0.46130.47470.40361.0000
V=
0.54070.1634-0.78540.2531
0.55190.16600.1560-0.8022
0.53800.25340.59680.5387
0.3369-0.93890.05190.0477
D=
3.1626000
00.726900
000.08820
0000.0223
P152T1
程序:
x=[1242;
2433;
3344;
4555]
geom=geomean(x)
harm=harmmean(x)
meanX=mean(x)
medianm=median(x)
rangem=range(x)
var1x=var(x,1)
stdX=std(x)
covX=cov(x)
moment1=moment(x,1)
moment2=moment(x,2)
moment3=moment(x,3)
moment4=moment(x,4)
R=corrcoef(x)
运行结果:
x=
1242
2433
3344
4555
geom=
2.21343.30983.93603.3098
harm=
1.92003.11693.87103.1169
meanX=
2.50003.50004.00003.5000
medianm=
2.50003.50004.00003.5000
rangem=
3323
var1x=
1.25001.25000.50001.2500
stdX=
1.29101.29100.81651.2910
covX=
1.66671.33330.66671.6667
1.33331.66670.33331.3333
0.66670.33330.66670.6667
1.66671.33330.66671.6667
moment1=
0000
moment2=
1.25001.25000.50001.2500
moment3=
0000
moment4=
2.56252.56250.50002.5625
R=
1.00000.80000.63251.0000
0.80001.00000.31620.8000
0.63250.31621.00000.6325
1.00000.80000.63251.0000
T2
X=[12345678910]'*[10987654321]
geom=geomean(x)
harm=harmmean(x)
meanX=mean(x)
medianm=median(x)
rangem=range(x)
var1x=var(x,1)
stdX=std(x)
covX=cov(x)
moment1=moment(x,1)
moment2=moment(x,2)
moment3=moment(x,3)
moment4=moment(x,4)
R=corrcoef(x)
X=
10987654321
2018161412108642
30272421181512963
403632282420161284
5045403530252015105
6054484236302418126
7063564942352821147
8072645648403224168
9081726354453627189
100908070605040302010
geom=
2.21343.30983.93603.3098
harm=
1.92003.11693.87103.1169
meanX=
2.50003.50004.00003.5000
medianm=
2.50003.50004.00003.5000
rangem=
3323
var1x=
1.25001.25000.50001.2500
stdX=
1.29101.29100.81651.2910
covX=
1.66671.33330.66671.6667
1.33331.66670.33331.3333
0.66670.33330.66670.6667
1.66671.33330.66671.6667
moment1=
0000
moment2=
1.25001.25000.50001.2500
moment3=
0000
moment4=
2.56252.56250.50002.5625
R=
1.00000.80000.63251.0000
0.80001.00000.31620.8000
0.63250.31621.00000.6325
1.00000.80000.63251.0000
P153T3
m=magic(5)
m([17131925])=[NaNNaNNaNNaNNaN]
nan=nansum(m)
min=nansum(m)
max=nanmax(m)
median=nanmedian(m)
std=nanstd(m)
运行结果:
m=
17241815
23571416
46132022
101219213
11182529
m=
NaN241815
23NaN71416
46NaN2022
101219NaN3
1118252NaN
nan=
4860524456
min=
4860524456
max=
2324252022
median=
10.500015.000013.000011.000015.5000
std=
7.95827.746010.95457.74607.9582
P179T1andT2
先建立俩个函数于.m文件中:
functiony=xbar(x)
n=length(x);
y=sum(x);
y=y./n;
functiony=sigma2(x)
Y=x-xbar(x);
Y2=Y.*Y;
n=length(x);
y=sum(Y2);
y=y./n;
T1
>>x=[2.3,4.0,5.4,3.4,4.3,3.4,2.8,4.5,4.3,4.2,3.8,3.7,3.2,3.6,3.5,3.4];
>>mu=xbar(x)
运行结果:
mu=
3.7375
T2
>>x=[3.2,3.3,3.4,3.6,3.7,3.8,4.1,4.0,4.2,3.9,3.1,3.0,3.3,3.2,3.2];
>>mu=xbar(x)
mu=
3.5333
运行结果:
>>sig=sigma2(x)
sig=
0.1436