Problem at hand: Set the seed at 1, then using a for-loop take a random sample of 5 mice 1,000 times. Save these averages.
What proportion of these 1,000 averages are more than 1 gram away from the average of x ?
My script:
set.seed(1)
weightsample<-vector("numeric", 1000)
for (i in 1:1000) {
random<-sample(x, 5)
weightsample[i]<-mean(random)
}
popmean<-mean(x)
mean(weightsample>popmean+1)
my erroneous answer:
0.265
Aucun commentaire:
Enregistrer un commentaire