I generated, in R, one hundred thousand random samples of ten values from the normal distribution with mean zero and unit standard deviation, and registered each mean and standard deviation, in hope to understand better their distribution.

moy <- c()
std <- c()
N <- 100000
for(i in 1:N){
    sam <- rnorm(10)
    moy <- c(moy,mean(sam))
    std <- c(std,sd(moy))
hist(std, n=10000, xlim=c(0.312,0.319))

What I wasn't expecting is shown here on the histogram of standard deviation of samples, which shows clear grouping of samples' SD estimates at/around some values more than expected :

histogram of sample's SD

My question is then, is there any logical cause for such strange distribution of samples' SD ?

Actually I was expecting some kind of normal (or very close to normal) distribution. I don't see any reason for this strange distribution apart from, maybe, the random number generator of R not generating quite random numbers. But maybe there is some mathematical cause for what is observed here ?

Thanks in advance.


1 Answer 1


You've got a bug; you're taking sd of moy rather than sam. I bet your code is also pretty slow; a more R-like method would be as follows.

N <- 100000
n <- 10
d <- matrix(rnorm(N*n), nrow=10)
m <- colMeans(d)
s <- apply(d, 2, sd)

hist(s, 10000)
  • $\begingroup$ Holy #!$ so that was that ! Thank you very much for pointing out that mistake so fast. And yeah I noticed it slowed down as time went on during the running. Didn't know why... That remembers me not to try things too late at night. And thanks for the code. $\endgroup$
    – Rodolphe
    Mar 19, 2016 at 0:25
  • $\begingroup$ Maybe this strange distribution reflects the bouncing back and forth of standard deviation of the mean as the number of sample increase... $\endgroup$
    – Rodolphe
    Mar 19, 2016 at 0:32
  • $\begingroup$ What the 'm' variable has been calculated for? There is no further use of 'm'. You wanted the difference d and m. $\endgroup$
    – Maximilian
    Mar 24, 2016 at 19:38
  • $\begingroup$ I think you're right. I calculated m to parallel the OP code. $\endgroup$ Mar 24, 2016 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.