Stratified Sampling

The purpose behind stratified sampling is to split up our domain into regions and sample points from each region. Allowing each region to provide a proportional share of points and combining to get a better estimate of our example of \(\int_{0}^{1} e^{-x}(1+x^2)^{-1} dx\). - http://statweb.stanford.edu/~owen/mc/Ch-var-basic.pdf

“We can achieve more reduction in variance using stratification when the means of the strata are widely disperses than if the means of the strata are approximately equal.” - Rizzo, Maria L. Statistical computing with R. Chapman & Hall/CRC, 2008. Below is an example from the text.

set.strat <- list(M = 120, rows = 20)
T2 <- numeric(8)
estimates <- matrix(0, set.strat$rows, 2)
g <- function (x) {
       exp(-x - log(1+x^2)) * (x > 0) * (x <1)}

for(i in 1:set.strat$rows){
  estimates[i, 1] <- mean(g(runif(set.strat$M)))
  bin <- seq(0, 1, by = 1/length(T2))
  for (j in 1:length(T2)){
  T2[[j]] <- mean(g(runif(set.strat$M/length(T2), bin[[j]], bin[[j+1]])))
  }
  estimates[i,2] <- mean(T2)
}
estimates
##            [,1]      [,2]
##  [1,] 0.5066316 0.5237318
##  [2,] 0.5168871 0.5244359
##  [3,] 0.5144469 0.5257734
##  [4,] 0.5188365 0.5208907
##  [5,] 0.5289581 0.5227612
##  [6,] 0.5472595 0.5278329
##  [7,] 0.4952693 0.5236447
##  [8,] 0.5443168 0.5288097
##  [9,] 0.5596946 0.5313003
## [10,] 0.5423059 0.5254466
## [11,] 0.5238439 0.5229566
## [12,] 0.5408202 0.5270024
## [13,] 0.5090165 0.5269460
## [14,] 0.5614450 0.5203036
## [15,] 0.4848482 0.5240193
## [16,] 0.5046529 0.5311417
## [17,] 0.5282921 0.5225888
## [18,] 0.5521623 0.5236883
## [19,] 0.5552154 0.5264564
## [20,] 0.5104375 0.5279405
apply(estimates, 2, mean)
## [1] 0.5272670 0.5253835
options(scipen = 999)
apply(estimates, 2, var)
## [1] 0.000497703254 0.000009303368

The text - http://statweb.stanford.edu/~owen/mc/Ch-var-basic.pdf - has a great example of stratified sample for Compound Poisson models for rainfall.