The function int() performs a Monte Carlo integration of the function f.

int(f, a, b, n = 10^5)

Arguments

f

the integrand

a

lower bound of integration

b

upper bound of integration

n

number of simulation, per default 10^5

Value

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

Examples

f <- function(x){x^2} MCint <- int(f, -2, 2) MCint$'Value of integral'
#> [1] 5.335682