# ARsim: ARsim In aumath-advancedr2019/ACM_2019: Monte Carlo methods

## Description

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.

## Usage

 ```1 2``` ```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

 ```1 2 3 4 5``` ```C <- 1.6 lambda <- 0.5 f <- function(x) {x*exp(-x)} ARsimulation <- ARsim(f, C, 100000, rate = lambda) ```

aumath-advancedr2019/ACM_2019 documentation built on Nov. 26, 2019, 2:07 a.m.