mercredi 10 juin 2020

R Why do I keep getting a different number of bins in histogram of means?

I am doing a histogram of means, where I sample 25 observations 1000 times. Everything works well apart from the fact that I keep getting a different number of bins.

Here's my code:

samp_25hist<-replicate(1000, {
   samp<-sample(df, 25, replace = F)
   mean(samp)
})
hist(samp_25hist, freq = F, breaks = 12,
     main = "Histogram of Means",
     ylab = "Y",
     xlab = "X",
     col = "orange")

I tried defining the number of bins, as you can see from the code, but I keep getting either 12, 13, or 14 bins.

Can anyone help me to sort this out?

Thanks!




Aucun commentaire:

Enregistrer un commentaire