x1 <- rnorm(51,180,50) x2 <- rnorm(320,c(rep(180,200),rep(250,120)),50) th.hat <- median(x2) - median(x1) B <- 1000 Tboot <- numeric(B) for (i in 1:B) { xx1 <- sample(x1,replace=TRUE) xx2 <- sample(x2,replace=TRUE) Tboot[i] <- median(xx2) - median(xx1) } se <- sqrt(var(Tboot)) Normal <- c(th.hat - (2 * se), th.hat + (2 * se)) percentile <- c(quantile(Tboot, 0.025), quantile(Tboot, 0.975)) pivotal <- c((2 * th.hat) - quantile(Tboot,0.975),(2 * th.hat) - quantile(Tboot,0.025))