The function ARsim() draws from the random variable, which is specified by the density f, using acceptance rejection sampling. The default proposal density is the exponential density with rate 1. If you want to use a different density you have to set the argument "exponential" to FALSE and specify your new proposal density and the corresponding inverse distribution function.

ARsim(f, C, N, exponential = TRUE, rate = 1, propdensity = NA,
  inveresepropdist = NA)

Arguments

f

target density

C

constant such that f(x) <= C*g(x)

N

number of samples

exponential

indicates if we want to use the exponential density as proposal

rate

corresponding rate

propdensity

alternative proposal if needed

inveresepropdist

corresponding inverse distribution function

Value

returns a list containing the value of the integral, the 0.95-confidence interval, number of simulations and the function f

Examples

C <- 1.6 lambda <- 0.5 f <- function(x) {x*exp(-x)} ARsimulation <- ARsim(f, C, 100000, rate = lambda)