# # Written by: # -- # John L. Weatherwax 2009-04-21 # # email: wax@alum.mit.edu # # Please send comments and especially bug reports to the # above email address. # #----- # Change the mean and standard deviation of the function we are drawing from: random_draw_of_means = function(n=25){ av = matrix( data=0, ncol=1, nrow=n ) for( ii in 1:n ){ y = rnorm( 100, mean=100, sd=10 ) m = mean(y) av[ii] = m } return(av) } # Get the distribution of the mean of n random draws: t = random_draw_of_means() d = density( t ) plot( d ) par(mfrow=c(1,3)) plot( density( random_draw_of_means() ) ) plot( density( random_draw_of_means() ) ) plot( density( random_draw_of_means() ) ) par(mfrow=c(1,1))