powered by
Stratified Sampling Method
SI.SSM(h, from, to, level, N)
Density function to be integrated
The start point
The end point
Stratification, number of intervals
The number of trials
Approximated integration
Estimated variance
# NOT RUN { ## To integrate exp(x) from -1 to 1 set.seed(0) h <- function(x){ exp(x) } N <- 100000 SSMresult <- SI.SSM(h,-1,1,10,N) I4 <- SSMresult[[1]] VarI4 <- SSMresult[[2]] # }
Run the code above in your browser using DataLab