### Paul Johnson 2006-07-25 ### replicate1_2006.R sampleSize <- 200 m1 <- 4 s1 <- 3 repls <- 100 mytitle <- paste("Replications=",repls,"SampleSize=",sampleSize,"Mean=",m1,"Std.Dev=",s1) means <- replicate(repls,mean(rnorm(sampleSize,mean=m1,sd=s1))) myhist <- hist(means, main=mytitle, breaks=15) # Display some results in text inside the histo # I know there should be a better way, but don't know it # Note that in text, \n has a "next line" effect mylabel <- paste("E(x)=",m1,"\nobserved mean=",round(mean(means),2),"\nobserved std.dev \nof means=",round(sd(means),2)) # This puts text into the histogram, guessing # the positions from the 6'th bin's position text(myhist$breaks[6],.8*max(myhist$counts),mylabel ,pos=2)