mci: Monte Carlo Integration with a normal distribution

View source: R/mci.R

Monte Carlo integration with a normal distributionR Documentation

Monte Carlo Integration with a normal distribution

Description

Monte Carlo Integration with a normal distribution.

Usage

mci(fun, R = 10^6)

Arguments

fun

A function denoting the inside part of the expectation to be computed.

R

The number of draws from the normal distribution.

Value

The result of the integral.

Author(s)

Michail Tsagris.

R implementation and documentation: Michail Tsagris mtsagris@uoc.gr.

References

Morgan B. J. (2018). Elements of simulation. Chapman & Hall/CRC.

See Also

riag, rbeta1

Examples

## 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)

Rfast2 documentation built on Aug. 8, 2023, 1:11 a.m.