[R] Integration of functions with a vector argument

Ivan Krylov |kry|ov @end|ng |rom d|@root@org
Thu Jun 20 17:37:39 CEST 2024


В Tue, 18 Jun 2024 23:12:03 +0000
"Levine, Michael" <mlevins using purdue.edu> пишет:

> I have heard of several packages used for numerical integration in R -
> cubature that you mentioned, mvQuad, and pracma.  My impression is
> that you think that Cubature is the best in your opinion. Is that so?

Yes, but the preference is not very strong. My own numerical
integration experience is limited to using QUADPACK in a project where
everything had to be rewritten in Fortran for speed.

I trust the code of the 'cubature' library by Steven G. Johnson (whose
work includes FFTW and NLopt) and the 'Cuba' library by Thomas Hahn.
The 'cubature' R package wraps these two libraries. Unfortunately, as
you see, its documentation can be lacking.

Like 'cubature', the 'mvQuad' package won't require a significant
rewrite of the integrand because it expects its functions to take
matrices of arguments. Unfortunately, the two packages differ in the
meanings they assign to the matrices: in 'cubature', individual
arguments of the function correspond to the rows of the first argument,
while in 'mvQuad', they must be in the columns.

The 'mvQuad' package requires manual adjustments to the generated
quadratures using rescale(...), which may be not very convenient.

The 'pracma' package contains implementations of a lot of excellent
methods (I've trusted it before for its other functions), but the (two-
or three-argument) integrand will have to be rewritten to accept
separate arrays (of arbitrary shape?) instead of a single matrix.

> If yes, do you know of any detailed discussion of this package beyond
> the two vignettes available on CRAN?

I don't know how much it can help, but more information about the
underlying code for 'cubature' can be found at
<https://github.com/stevengj/cubature> and <https://feynarts.de/cuba/>.

-- 
Best regards,
Ivan



More information about the R-help mailing list