Learn R Programming

sdetorus (version 0.1.10)

mcTorusIntegrate: Monte Carlo integration on the torus

Description

Convenience function for Monte Carlo integration on \([-\pi, \pi)^p\).

Usage

mcTorusIntegrate(f, p, M = 1e+05, fVect = TRUE, ...)

Value

A scalar with the approximated integral.

Arguments

f

function to be integrated.

p

dimension of the torus.

M

number of Monte Carlo replicates.

fVect

is f vectorized?

...

further parameters passed to f.

Examples

Run this code
# Integral of sin(x1) * cos(x2), must be close to 0
mcTorusIntegrate(f = function(x) sin(x[, 1]) * cos(x[, 2]), p = 2)

Run the code above in your browser using DataLab