## expected value and standard error of 1 through 7 box ## ADM 10/11/2007 ## specifics the.box <- 1:7 draws <- 25 ## perform simulation G <- 10000 holder <- rep(NA, G) for(g in 1:G) { holder[g] <- 1/draws * sum(sample(the.box, draws, replace=TRUE)) } ## plot the results plot(density(holder)) ## estimate the expected value from the simulation mean(holder) ## estimate the standard error from the simulation sd(holder)