R: Integration with SUbregion-Adaptive Vegas Algorithm
suave
R Documentation
Integration with SUbregion-Adaptive Vegas Algorithm
Description
Suave uses vegas-like importance sampling combined
with a globally adaptive subdivision strategy: Until the requested accuracy is reached,
the region with the largest error at the time is bisected in the dimension in which the
fluctuations of the integrand are reduced most. The number of new samples in each half
is prorated for the fluctuation in that half.
same as cuhre;
But, here, the input argument phw
contains the weight of the point being sampled.
This
extra value can safely be
ignored.
...
same as cuhre
lower
same as cuhre
upper
same as cuhre
rel.tol
same as cuhre
abs.tol
same as cuhre
flags
same as cuhre.
flags may have an additional component:
smooth. When = 0, apply additional smoothing to the importance
function, this moderately improves convergence for many integrands.
When = 1 , use the importance function without smoothing, this should be chosen
if the integrand has sharp edges.
min.eval
same as cuhre
max.eval
same as cuhre
nnew
the number of new integrand evaluations in each subdivision.
flatness
This parameter determines how
prominently “outliers”, i.e. individual samples with a large
fluctuation,
figure in the total fluctuation,
which in turn determines how a region is split up. As suggested by its name, flatness
should be chosen large for “flat” integrands and small for “volatile”
integrands with
high peaks. Note that since flatness appears in the exponent, one should not use
too large values (say, no more than a few hundred) lest terms be truncated internally
to prevent overflow. More details about this parameter can be found
Hahn's paper from 2005 and in Cuba documentation.
Details
See details in the documentation.
Value
Idem as cuhre
References
T. Hahn (2005) CUBA-a library for multidimensional numerical
integration. Computer Physics Communications, 168, 78-95.
See Also
cuhre, divonne, vegas
Examples
integrand <- function(arg, weight) {
x <- arg[1]
y <- arg[2]
z <- arg[3]
ff <- sin(x)*cos(y)*exp(z);
return(ff)
} # end integrand
suave(3, 1, integrand, rel.tol=1e-3, abs.tol=1e-12,
flags=list(verbose=2, final=0))
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(R2Cuba)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/R2Cuba/suave.Rd_%03d_medium.png", width=480, height=480)
> ### Name: suave
> ### Title: Integration with SUbregion-Adaptive Vegas Algorithm
> ### Aliases: suave
> ### Keywords: math
>
> ### ** Examples
>
> integrand <- function(arg, weight) {
+ x <- arg[1]
+ y <- arg[2]
+ z <- arg[3]
+ ff <- sin(x)*cos(y)*exp(z);
+ return(ff)
+ } # end integrand
> suave(3, 1, integrand, rel.tol=1e-3, abs.tol=1e-12,
+ flags=list(verbose=2, final=0))
Suave input parameters:
ndim 3
ncomp 1
rel.tol 0.001
abs.tol 1e-12
smooth 0
pseudo.random 0
final 0
verbose 2
min.eval 0
max.eval 50000
nnew 1000
flatness 50
Iteration 1: 1000 integrand evaluations so far
[1] 0.664916 +- 0.0138647 chisq 0 (0 df)
Iteration 2: 2000 integrand evaluations so far
[1] 0.664343 +- 0.0046336 chisq 0.00737292 (2 df)
Iteration 3: 3000 integrand evaluations so far
[1] 0.664623 +- 0.0026616 chisq 1.09695 (5 df)
Iteration 4: 4000 integrand evaluations so far
[1] 0.664393 +- 0.00118042 chisq 1.60235 (8 df)
Iteration 5: 5000 integrand evaluations so far
[1] 0.664433 +- 0.000802054 chisq 2.52582 (12 df)
Iteration 6: 6000 integrand evaluations so far
[1] 0.664746 +- 0.000612748 chisq 4.38844 (16 df)
integral: 0.6647464 (+-0.00061)
nregions: 6; number of evaluations: 6000; probability: 0.001946077
>
>
>
>
>
> dev.off()
null device
1
>