# This R code pertains to Sec. 7.4 of E&T. # # Let's see how well nonparametric bootstrapping can # estimate the standard error of the sample maximum # when the data comes from a uniform distribution. # # First I'll generate a sample of size 50 from a # uniform (0, 1) distribution. set.seed(321) x <- runif(50, 0, 1) # # Now I'll generate 2000 bootstrap samples and estimate # the standard error of the sample maximum. bss <- matrix( sample( x, size=2000*length(x), replace=T ), nrow=2000 ) replicates <- apply( bss, 1, max ) # # Here's the bootstrap estimate of the standard error: sd(replicates) # # Here's a histogram of the replicates: hist(replicates) # # Here's the true value of the standard error: sqrt( 50/52 - (50/51)^2 ) # # Here's a parametric estimate of the standard error: max(x)*sqrt( 50/52 - (50/51)^2 ) # # It can be concluded that bootstrapping doesn't work very # well in this situation.