utils-adapt: Integrator for multivariate distributions

utils-adaptR Documentation

Integrator for multivariate distributions

Description

The function is for adaptive quadrature.

Usage

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

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.

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.

Note

In 2007 the package adapt was removed from the CRAN repository, due to unclear license conditions. Nevertheless, formerly available versions can still be obtained from the CRAN archive. Package adapt used FORTRAN code from Professor Genz.

From 2007 until 2013 the package fMultivar used an builtin licensed by Professor Genz to Rmetrics. This version is still available in the current package, have a look into the folder deprecated.

2013 the contributed package cubature was added to the CRAN repository. This provides an alternative n-dimensional integration routine. We recommend to use the function adaptIntegrate directly from the package cubature which allows adaptive multivariate integration over hypercubes. It is a wrapper around the pure C, GPLed implementation by Steven G. Johnson.

Since 2014 fMultivar uses also the C Version based implementation of Johnson. The former function adapt has been replaced by a wrapper function calling adaptIntegrate. The arguments ndim, lower, upper, and functn have been remeined the same, control parameters have been adapted to the function cubature::adaptIntegrate.

Author(s)

Balasubramanian Narasimhan

References

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

Examples


## 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


fMultivar documentation built on July 9, 2023, 3:08 p.m.