mcint: Monte Carlo Integration

Description Usage Arguments Details Value See Also Examples

View source: R/mcintegrate.R

Description

Simple Monte Carlo Integraton

Usage

1
2
3
mcint(f, a, b, m = 1000)

mcint2(f, xdom, ydom, m = 1000)

Arguments

f

function to integrate

a

the lower-bound of integration

b

the upper-bound of integration

m

the number of subintervals to calculate

xdom

the domain on x of integration in two dimensions

ydom

the domain on y of integration in two dimensions

Details

The mcint function uses a simple Monte Carlo algorithm to estimate the value of an integral. The parameter n sets the total number of evaluation points. The parameter max.y is the maximum expected value of the range of function f. The mcint2 provides Monte Carlo integration in two dimensions.

Value

the value of the integral

See Also

Other integration: adaptint(), gaussint(), giniquintile(), midpt(), revolution-solid, romberg(), simp38(), simp(), trap()

Examples

1
2
3
f <- function(x) { sin(x)^2 + log(x)}
mcint(f, 0, 1)
mcint(f, 0, 1, m = 10e6)

cmna documentation built on July 14, 2021, 5:11 p.m.