P37.
?/p>
2.1
build.price<-
c(36,32,31,25,28,36,40,32,41,26,35,35,32,87,33,35
);build.price
hist(build.price,freq=FALSE)#
直方?/p>
lines(density(build.price),col="red")#
连线
#
方法一?/p>
m<-mean(build.price);m#
均?/p>
D<-var(build.price)#
方差
SD<-sd(build.price)#
标准?/p>
S
t=(m-37)/(SD/sqrt(length(build.price)));t#t
统计?/p>
计算检验统计量
t=
[1] -0.1412332
#
方法二:
t.test(build.price-37)#
课本?/p>
38
?/p>
?/p>
2.2
binom.test(sum(build.price<37),length(build.price),
0.5)#
课本
40
?/p>
?/p>
2.3
P<-2*(1-pnorm(1.96,0,1));P
[1] 0.04999579
P1<-2*(1-pnorm(0.7906,0,1));P1
[1] 0.4291774
>
?/p>
2.4
> p<-2*(pnorm(-1.96,0,1));p
[1] 0.04999579
>
> p1<-2*(pnorm(-0.9487,0,1));p1
[1] 0.3427732
?/p>
2.5
?/p>
P45
?/p>
scores<-
c(95,89,68,90,88,60,81,67,60,60,60,63,60,92,
60,88,88,87,60,73,60,97,91,60,83,87,81,90);length(
scores)#
输入向量求长?/p>
ss<-c(scores-80);ss
t<-0
t1<-0
for(i in 1:length(ss)){
if (ss[i]<0) t<-t+1#
求小?/p>
80
的个?/p>
else t1<-t1+1
求大?/p>
80
的个?/p>
}
t;t1
> t;t1
[1] 13
[1] 15
binom.test(sum(scores<80),length(scores),0.75)
p-value = 0.001436<0.01
Cox-Staut
趋势存在性检?/p>
P47
?/p>
2.6
year<-1971:2002;year
length(year)
rain<-
c(206,223,235,264,229,217,188,204,182,230,223,
227,242,238,207,208,216,233,233,274,234,227,221
,214,
226,228,235,237,243,240,231,210)
length(rain)
#(1)
该地区前
10
年降雨量是否变化?/p>
t1=0
for (i in 1:5){
if (rain[i]<rain[i+5]) t1<-t1+1
}
t1
k<-0:t1-1
sum(dbinom(k,5,0.5))# =0.1875
y<-6/(2^5);y# =0.1875