# # 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. # #----- # Part (c): # random_draw_of_means = function(n=25){ av = matrix( data=0, ncol=1, nrow=n ) # initialize storage of the means for( ii in 1:n ){ y = rnorm( 100 ) 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))