powered by
Stochastic Point Method
SI.SPM(h, from, to, M, N)
Density function to be integrated
The start point
The end point
The upper bound of h(x) in [from,to]
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 SPMresult <- SI.SPM(h,-1,1,exp(1),N) I1 <- SPMresult[[1]] VarI1 <- SPMresult[[2]] # }
Run the code above in your browser using DataLab