若干年前學過R語言的選修課轮听, 現在忘了個一干二凈
> c <- rnorm(100,5)
> t.test(c,mu=100)
One Sample t-test
data: c
t = -1095.3, df = 99, p-value < 2.2e-16
alternative hypothesis: true mean is not equal to 100
95 percent confidence interval:
4.789196 5.133539
sample estimates:
mean of x
4.961367
> t.test(c,mu=5)
One Sample t-test
data: c
t = -0.44523, df = 99, p-value = 0.6571
alternative hypothesis: true mean is not equal to 5
95 percent confidence interval:
4.789196 5.133539
sample estimates:
mean of x
4.961367
首先是創(chuàng)建了一個正態(tài)分布的向量c,100個元素,均值為5.
下面檢驗一下c這個向量是不是來自均值為mu的正態(tài)分布
(mu=100的時候當然不符合了岭佳,結果也顯示p很醒 )
(mu=5的時候,p是0.6幾珊随,不能拒絕替代假設)
哦好的述寡,書上說mu是形參,我?guī)缀跻呀浲诉@個詞(形參實參這種詞就是用來迷惑人的叶洞,誰發(fā)明了這倆詞鲫凶,真夠有毛病的)
> d<- a^2
> plot(a,d)
d=a^2