数学建模第五次作业
- 格式:doc
- 大小:38.00 KB
- 文档页数:5
1. 区间估计
解:R程序:
X <- c(1067, 919, 1196, 785, 1126, 936, 918, 1156, 920, 948);
n <- length(X);
xb <- mean(X);
S2 <- var(X);
S <- sqrt(S2);
T = (xb-1000)/(S/sqrt(n));
结果:
mean df a b
1 997.1 9 902.9965 1091.203
p-value=0.5270268
由此可知:置信区间为902.996到1096.203,该批灯泡能使用1000小时以上的概率为52.70268%。
2. 假设检测I
解:假设H0<=225,H1>225
此问题是单边检验输入数据,调用函数t.test()
R程序:
X<-c(220, 188, 162, 230, 145, 160, 238, 188,247,113,
126, 245, 164, 231, 256, 183, 190, 158,224,175)
t.test(X, alternative = "greater", mu = 225)
结果:
data: X
t = -3.4783, df = 19, p-value = 0.9987
alternative hypothesis: true mean is greater than 225
95 percent confidence interval:
175.8194 Inf
sample estimates:
mean of x
192.15
由此可知:P值为0.9987,不能拒绝原假设,接受H0,即认为油漆工人的血小板计数与正常成年男子有差异,油漆作业对人体血小板计数有影响。
3. 假设检测II
解:(1)两总体方差相同模型选择t检验法
R程序:
X<-c(113,120,138,120,100,118,138,123)
Y<-c(138,116,125,136,110,132,130,110)
t.test(X, Y, alternative = "less", var.equal=TRUE)
t.test(X, Y, alternative = "less")
结果:
Two Sample t-test
data: X and Y t = -0.566, df = 14, p-value = 0.2902
alternative hypothesis: true difference in means is less than 0
95 percent confidence interval:
-Inf 7.12812
sample estimates:
mean of x mean of y
121.250 124.625
(2)两总体方差不同模型
R程序:
X<-c(113,120,138,120,100,118,138,123)
Y<-c(138,116,125,136,110,132,130,110)
var.test(X, Y)
结果:
F test to compare two variances
data: X and Y
F = 1.2278, num df = 7, denom df = 7, p-value = 0.7935
alternative hypothesis: true ratio of variances is not equal to 1
95 percent confidence interval:
0.2458103 6.1327511
sample estimates:
ratio of variances
1.227800
(3)成对数据模型
R程序:
X<-c(113,120,138,120,100,118,138,123)
Y<-c(138,116,125,136,110,132,130,110)
var.test(X, Y, alternative = "less", exact=F)
结果:
F test to compare two variances
data: X and Y
F = 1.2278, num df = 7, denom df = 7, p-value = 0.6033
alternative hypothesis: true ratio of variances is less than 1
95 percent confidence interval:
0.000000 4.649733
sample estimates:
ratio of variances
1.227800
由此可知:(1)p=0.29(2)p=0.79(3)p=0.60,置信区间(1)>(2)>(3)。
4. 假设检测III
解:由题可知所检验的问题为H0: p=p0=0.147, H1: p≠p0。调用binom.test()
函数 :binom.test(57,400,p=0.147)
结果 :
data: 57 and 400 number of successes = 57, number of trials = 400, p-value = 0.8876
alternative hypothesis: true probability of success is not equal to
0.147
95 percent confidence interval: 0.1097477 0.1806511
sample estimates: probability of success 0.1425
由此可知:P-值为0.8876>0.05,接受假设,所以该结果支持该城市老年人口的比重为14.7%的说法。
5. 分布检测I
解:
调用chisq.test()函数 chisq.test(c(315,101,108,32),p=c(9,3,3,1)/16)
结果:
> chisq.test(c(315,101,108,32),p=c(9,3,3,1)/16)
Chi-squared test for given probabilities
data: c(315, 101, 108, 32)
X-squared = 0.47, df = 3, p-value = 0.9254
由此可知:p-value = 0.9254>0.05 接受原假设,即豌豆两对性状的分离符合自由组合规律。
6. 分布检测II
解:R程序:
输入数据
X<-0:5; Y<-c(92, 68, 28, 11, 1, 0)
计算理论分布, 其中mean(rep(X,Y))为样本均值
q<-ppois(X, mean(rep(X,Y))); n<-length(Y)
p<-q[1]; p[n] <- 1-q[n-1]
for (i in 2:(n-1))
p[i] <- q[i]-q[i-1]
作检验
chisq.test(Y, p=p)
结果:
Chi-squared test for given probabilities
data: Y
X-squared = 2.1596, df = 5, p-value = 0.8267
Warning message:
In chisq.test(Y, p = p) : Chi-squared近似算法有可能不准
重新分组
Z<-c(92, 68, 28, 12)
重新计算理论分布
n<-length(Z); p<-p[1:n-1]; p[n]<-1-q[n-1]
作检验
chisq.test(Z, p=p)
结果:
Chi-squared test for given probabilities
data: Z
X-squared = 0.9113, df = 3, p-value = 0.8227 由此可知:第一个p-value = 0.8267>0.1但是出现了警告,所以需要重新分组。Pearson x2要求分组后,每组中的频数至少要大于等于5,而后两组中的频数均小于5,并且它们的和仍然小于5,而后三组中的频数相加后大于5。因此需求将后三组合成一组,此时的频数为12。分组后得到的p-value = 0.8227>0.1 因此,可以认为每分钟顾客数X服从Poisson分布。
7. 列链表检测I
解:假设:使用电子婴儿监测仪与剖腹产率无关
R程序:> x <- c(358, 2492, 229, 2745)
> x <- matrix(x, nc=2)
> chisq.test(x, correct = FALSE)
结果:
Pearson's Chi-squared test
data: x
X-squared = 37.9488, df = 1, p-value = 7.263e-10
> chisq.test(x)
Pearson's Chi-squared test with Yates' continuity correction
data: x
X-squared = 37.4143, df = 1, p-value = 9.552e-10
由此可知:p-value值小于0.05 经Yate修正,结果一致,避免2×2的列联表P-值偏小,所以拒绝假设,证明使用婴儿电子监测仪和剖腹产率相关。
8. 列链表检测II
解:R程序:
x<-matrix(c(3,6,4,4),nc=2)
fisher.test(x)
结果:
Fisher's Exact Test for Count Data
data: x
p-value = 0.6372
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
0.04624382 5.13272210
sample estimates:
odds ratio 0.521271
由此可知:p-value = 0.6372>0.05 并且区间估计得到的区间包含有1,因此两变量是独立的,所以两种工艺对产品的质量无影响。
9. Wilcoxon秩和检测I
解:(1)R程序:
x<-c(3, 5, 7, 9, 10); y<-c(1, 2, 4, 6, 8)
wilcox.test(x, y, alternative="greater")
结果:
Wilcoxon rank sum test
data: x and y