mc_int: Simple Monte-Carlo integrationde

Description Usage Arguments Examples

Description

Compute an approximation of the integral of the function f(x) with respect to dx in the range [a, b] by Monte-Carlo integration using uniform sampling.

Usage

1
mc_int(x_range, fun, B, seed = 1291)

Arguments

x_range

A vector of dimension 2 used to denote the integration region of interest, i.e. [a, b].

fun

A string containing the function to be integrated. It is assumed that x is used as the variable of interest.

B

A numeric (integer) used to denote the number of simulations.

Examples

1
2
mc_int(x_range = c(0,1), fun = "x^2", B = 10^5)
mc_int(x_range = c(0,1), fun = "x^2*sin(x^2/pi)", B = 10^5)

khanimzul/demo documentation built on May 8, 2019, 6:52 p.m.