integrate.mv: Multivariate Integration

Description Usage Arguments Details Value Note Examples

View source: R/integrate.mv.R

Description

Integrate a multivariate function (R^p -> R).

Usage

1
integrate.mv(f, lower, upper, stop.on.error = FALSE, ...)

Arguments

f

Function that takes a vector and returns a numeric.

lower,

upper Vector of the limits of integration for each variable entered into f. Can be infinite.

stop.on.error

Logical (an argument of integrate) – should function be stopped if an "error" occurs?

...

Other arguments to pass into integrate.

Details

This function recursively integrates the arguments in f using the integrate function.

It's reasonably fast when f takes two variables, and slow when f takes 3 variables. For 4 or more, perhaps look into alternative approaches.

If you're support is finite, you're better off using cubature::adaptIntegrate.

Value

A numeric value of the integral. The other information outputted by the integrate function are ignored.

If the length of the limit vectors is zero, it will be assumed that f has no arguments, so f() will be returned. returned.

Note

Only a rectangular support is allowed.

This function could probably be improved if some of the support is finite, in which case somehow cubature::adaptIntegrate could be leveraged somehow.

The stop.on.error argument is defaulted to FALSE instead of integrate's TRUE because sometimes it'll think the integral is divergent when it's really not.

Examples

1
2
3

vincenzocoia/copsupp documentation built on Aug. 23, 2020, 7:37 a.m.