Learn R Programming

fMultivar (version 4031.84)

utils-adapt: Integrator for multivariate distributions

Description

The function is for adaptive quadrature.

Usage

adapt(ndim, lower, upper, functn, ...)

Value

The returned value is a list of three items:

integral

the value of the integral.

error

the estimated relative error.

functionEvaluations

the number of times the function was evaluated.

returnCode

the actual integer return code of the C routine.

Arguments

ndim

the dimension of the integral. By default NUll, no longer used.

lower

vector of at least length ndim of the lower bounds on the integral.

upper

vector of at least length ndim of the upper bounds on the integral.

functn

an R function which should take a single vector argument and possibly some parameters and return the function value at that point. functn must return a single numeric value.

...

other parameters to be passed to the underlying function.

Author

Balasubramanian Narasimhan

References

See: http://ab-initio.mit.edu/wiki/index.php/Cubature.

Examples

Run this code
# \donttest{
## Check that dnorm2d is normalized:
  
   # Normal Density:
   density <- function(x) dnorm2d(x=x[1], y = x[2])
      
   # Calling Cubature:
   BIG <- c(99, 99)
   cubature::adaptIntegrate(f=density, lowerLimit=-BIG, upperLimit=BIG)
   cubature::adaptIntegrate(f=density, low=-BIG, upp=BIG, tol=1e-7)
    
   # Using the Wrapper:
   adapt(lower=-BIG, upper=BIG, functn=density) 
   adapt(lower=-BIG, upper=BIG, functn=density, tol=1e-7)$integral
# }

Run the code above in your browser using DataLab