#Draw 6 values from a N(0,1) distribution and calculate #the variance using the true population mean and the #mean calculated from the sample - repeat 1E6 times n <- 6 m <- 1E+6 mu <- 0 sigma <- 1 v.pop <- numeric(m) v.sam <- numeric(m) for (i in 1:m) { x <- rnorm(n,mu,sigma) x.bar <- mean(x) v.sam[i] <- sum((x-x.bar)^2) / n v.pop[i] <- sum((x-mu)^2) / n } #if you use the true population mean to calculate the estimate of #the population variance, on the average you will get a good estimate ...