The package provides implementations of test functions for multivariate numerical integration that can be used to test multivariate integration routines. The package covers six different integration domains (unit hypercube, unit ball, unit sphere, standard simplex, non-negative real numbers and R^n). For each domain several functions with different properties (smooth, non-differentiable, ...) are available. The functions are available in all dimensions n >= 1. For each function the exact value of the integral is known and implemented to allow testing the accuracy of multivariate integration routines. Details on the available test functions and the value of their integral can be found in documentation_test_functions.pdf.
The key features of the package are
- a unified, intuitive and object oriented interface;
- that the implemented functions are available for any dimension n>= 1. This facilitates the test of high dimensional integration routines and allows to gauge the behaviour when the number of dimensions n changes;
- that the package provides a number of different functions and integration domains.
To define a test function, the keyword new is used together with the type of test function and the relevant parameters.
For example, the class Rn_Gauss implements the function
f(x1,...,xn) = exp(- ∑k=1nxk2),
for which the value of the integral is known to be
∫-∞∞ ... ∫-∞∞ f(x1,...,xn) dx1 ... dxn = (π)n/2.
In R we can define the function, evaluate it for a given set of points and retrieve the theoretical value of the integral as follows:
require(multIntTestFunc)
n <- as.integer(3)
f <- new("Rn_Gauss",dim=n)
x <- matrix(c(0,0,0, 1,0,0, 0,1,0, 0,0,1),4,3,byrow = TRUE)
eval <- evaluate(f,x) #evaluate f(x) for x=(0,0,0), x=(1,0,0), x=(0,1,0) and x=(0,0,1)
print(eval)
print(exactIntegral(f))The stable version of the package is available on CRAN at https://cran.r-project.org/web/packages/multIntTestFunc/index.html and can be installed as usual.
To install the latest version from GitHub either clone the repository with git or download the ZIP file.
In both cases stick with the main branch.
In R navigate with setwd to the sub-folder multIntTestFunc and run
#setwd("...YOUR PATH TO multIntTestFunc...")
devtools::document()
devtools::build()
devtools::install()To get the latest development version follow the same steps but clone from branch development.
To add a function two steps are necessary:
- Describe the function in the reference manual
documentation_test_functions.texincluding possible sources in the bib file. It is also necessary to update the tables at the end of the file and to add the compileddocumentation_test_functions.pdfto the repository. - Create a R file for the function in the R directory following the naming convention
DOMAION_NAME.R. The implementation has to implement all inherited methods (with Roxygen comments). For thegetReferencesmethod an identifier for the section indocumentation_test_functions.texhas to be included as the first element of the vector.