data<-rnorm(20,mean=0,sd=1)#生成服从标准正态分布的随机变量
testb<-t.test(data)#利用t检验求data的均值(因为所有题目里还有置信区间,所以没有直接用mean)
testb
One Sample t-test
data: data
t = 1.7295, df = 19, p-value = 0.09994
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval:
-0.08077141 0.84920347
sample estimates:
mean of x #这里应该是真实均值吧?
0.384216