Trying to run the follow rgeom 500 times and store the mean and sd for each replication.
rgeom(100, prob = .2)
so far I have:
geom_means = rep(NA, 500)
geom_sd = rep(NA, 500)
X_geom500 <- replicate(500, {
samp <- rgeom(100, prob = .2)
geom_means = round(mean(samp),2)
})
X_geom500_sd <- replicate(500, {
samp <- rgeom(100, prob = .2)
round(sd(samp),2)
})
I can get a vector of 500 means and 500 sd's if I run the code separately but I don't think they are matching. I tried creating a for loop to store the means and SD for each iteration but I don't think it worked right.
for i in range(1:500):
sample[i] <- rgeom(100, prob = .2)
geom_means[i] <- mean(sample[i])
geom_sd[i] <- sd(sample[i])
Aucun commentaire:
Enregistrer un commentaire