SI.ISM {SI} | R Documentation |
Important Sampling Method
Description
Important Sampling Method
Usage
SI.ISM(h, g, G_inv, N, min_G = 0, max_G = 1)
Arguments
h |
Density function to be integrated |
g |
Sampling density function |
G_inv |
The inverse function of sampling distribution function |
N |
The number of trials |
min_G |
The min value of G |
max_G |
The max value of G |
Value
I |
Approximated integration |
Var |
Estimated variance |
Examples
## To integrate exp(x) from -1 to 1
## Use the sampling density (3/2+x)/3
set.seed(0)
h <- function(x){
exp(x)
}
N <- 100000
g <- function(x){return((3/2+x)/3)}
G_inv <- function(y){return(sqrt(6*y+1/4)-3/2)}
ISMresult <- SI.ISM(h,g,G_inv,N)
I3 <- ISMresult[[1]]
VarI3 <- ISMresult[[2]]
[Package SI version 0.2.0 Index]