Monte Carlo integration with a normal distribution | R Documentation |
Monte Carlo Integration with a normal distribution.
mci(fun, R = 10^6)
fun |
A function denoting the inside part of the expectation to be computed. |
R |
The number of draws from the normal distribution. |
The result of the integral.
Michail Tsagris.
R implementation and documentation: Michail Tsagris mtsagris@uoc.gr.
Morgan B. J. (2018). Elements of simulation. Chapman & Hall/CRC.
riag, rbeta1
## compute the expectation of abs(x)
fun <- function(x) abs(x)
mci(fun, R = 10^5)
a <- function(x) abs(x) * dnorm(x)
integrate(a, -Inf, Inf)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.