suave's.
cuhre(ndim, ncomp, integrand, ..., lower=rep(0,ndim), upper=rep(1,ndim), rel.tol= 0.001, abs.tol = 0, flags=list(verbose=1, final=1, pseudo.random=0, mersenne.seed=NULL), min.eval=0, max.eval=50000, key=0)integrand <- function(x, ...) or integrand <- function(x, phw, ...)
where x is an input vector of length ndim,
and phw an ignored argument for compatibility with
the other 'R2Cuba' functions.
... denotes optional additional arguments which
correspond to those
passed to the main function in ....
The value returned by this R function should be a vector of length
ncomp.
integrand, if any ndimndimverbose: verbose encodes the verbosity level, from. 0 to 3.
Level 0 does not print any output, level 1 prints reasonable information on the
progress of the integration, level 2 also echoes the input parameters, and level
3 further prints the subregion results.- final: when 0, all sets of samples collected on a subregion during the
various iterations or phases contribute to the final result.
When 1, only the last (largest) set of samples is used in the final
result.
- pseudo.random: (ignored in cuhre)
when 0, Sobol quasi-random numbers are used for sampling.
When 1, Mersenne Twister pseudo-random numbers are used for
sampling.
- mersenne.seed: (ignored in cuhre)
the seed for the Mersenne Twister algorithm, when
pseudo.random=1 and when it would be explicitly set.
key = 7, 9, 11, 13 selects the cubature rule of degree key. Note that the degree-11
rule is available only in 3 dimensions, the degree-13 rule only in 2
dimensions.For other values, the default rule is taken, which is the degree-13 rule in 2 dimensions, the degree-11 rule in 3 dimensions, and the degree-9 rule otherwise.
cuba with components:
ifail = 0 , the desired accuracy was reached,ifail = -1, dimension out of range,ifail = 1, the accuracy goal was not met within the allowed
maximum number of integrand evaluations.ncomp;
the integral of integrand over the
hypercube.ncomp;
the presumed absolute error of value.ncomp;
the $Chi2$-probability (not the $Chi2$-value itself!)
that abs.error is not a reliable estimate of the true integration
error.T. Hahn (2005) CUBA-a library for multidimensional numerical integration. Computer Physics Communications, 168, 78-95.
vegas, suave, divonne integrand <- function(arg) {
x <- arg[1]
y <- arg[2]
z <- arg[3]
ff <- sin(x)*cos(y)*exp(z);
return(ff)
} # End integrand
NDIM <- 3
NCOMP <- 1
cuhre(NDIM, NCOMP, integrand,
rel.tol= 1e-3, abs.tol= 1e-12,
flags= list(verbose=2, final=0))
Run the code above in your browser using DataLab