utils-adapt | R Documentation |
The function is for adaptive quadrature.
adapt(ndim, lower, upper, functn, ...)
ndim |
the dimension of the integral. By default NUll, no longer used. |
lower |
vector of at least length |
upper |
vector of at least length |
functn |
an R function which should take a single vector argument and
possibly some parameters and return the function value at
that point. |
... |
other parameters to be passed to the underlying function. |
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. |
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
.
Balasubramanian Narasimhan
See: http://ab-initio.mit.edu/wiki/index.php/Cubature.
## 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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.