# First load PASWR library that has specialized functions. # library(PASWR) # Example 6.4 # Set parameters set.seed(2009) alpha=2 beta=5 m=500 #Set up graphing window as in text par(mfrow=c(2,2)) n=5 MEANSweibull=array(0,m) for (i in 1:m) {MEANSweibull[i]<-mean(rweibull(n,alpha,beta))} # Plot histogram of simulated sampling distribution hist(MEANSweibull,prob=T,xlab="xbar",xlim=c(1,9),nclass="scott",main=paste("n=",n)) n=10 MEANSweibull=array(0,m) for (i in 1:m) {MEANSweibull[i]<-mean(rweibull(n,alpha,beta))} # Plot histogram of simulated sampling distribution hist(MEANSweibull,prob=T,xlab="xbar",xlim=c(1,9),nclass="scott",main=paste("n=",n)) n=20 MEANSweibull=array(0,m) for (i in 1:m) {MEANSweibull[i]<-mean(rweibull(n,alpha,beta))} # Plot histogram of simulated sampling distribution hist(MEANSweibull,prob=T,xlab="xbar",xlim=c(1,9),nclass="scott",main=paste("n=",n)) n=30 MEANSweibull=array(0,m) for (i in 1:m) {MEANSweibull[i]<-mean(rweibull(n,alpha,beta))} # Plot histogram of simulated sampling distribution hist(MEANSweibull,prob=T,xlab="xbar",xlim=c(1,9),nclass="scott",main=paste("n=",n))