? Tue, 18 Jun 2024 23:12:03 +0000 "Levine, Michael" <mlevins at 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
If you haven't already done so, you may wish to have a look here: https://cran.r-project.org/web/views/NumericalMathematics.html#differentiation-and-integration (Or perhaps in other related subtopics in the Numerical Math task view) Cheers, Bert On Thu, Jun 20, 2024 at 8:37?AM Ivan Krylov via R-help <r-help at r-project.org> wrote:> ? Tue, 18 Jun 2024 23:12:03 +0000 > "Levine, Michael" <mlevins at 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 > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
Dear Ivan, Thank you very much again for your suggestions! I will try to use Cubature, then. yours sincerely, Michael Michael Levine Associate Professor, Statistics Department of Statistics Purdue University 250 North University Street West Lafayette, IN 47907 USA email: mlevins at purdue.edu Phone: +1-765-496-7571 Fax: +1-765-494-0558 URL: www.stat.purdue.edu/~mlevins ________________________________ From: Ivan Krylov <ikrylov at disroot.org> Sent: Thursday, June 20, 2024 11:37 AM To: Levine, Michael <mlevins at purdue.edu> Cc: r-help at r-project.org <r-help at r-project.org> Subject: Re: [R] Integration of functions with a vector argument ---- External Email: Use caution with attachments, links, or sharing data ---- ? Tue, 18 Jun 2024 23:12:03 +0000 "Levine, Michael" <mlevins at 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://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fstevengj%2Fcubature&data=05%7C02%7Cmlevins%40purdue.edu%7Cebdca9b21fa14410c84308dc913eed65%7C4130bd397c53419cb1e58758d6d63f21%7C0%7C0%7C638544946662774955%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=jflgsS7UUtmkgKyWyYuKxHtJNBpWA0eSbPQRWxEHOTk%3D&reserved=0<https://github.com/stevengj/cubature>> and <https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Ffeynarts.de%2Fcuba%2F&data=05%7C02%7Cmlevins%40purdue.edu%7Cebdca9b21fa14410c84308dc913eed65%7C4130bd397c53419cb1e58758d6d63f21%7C0%7C0%7C638544946662793433%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=kRblrnUyftzdC7SKqJrVQ9rLjpSX3ySWJK%2FCzhWYAvE%3D&reserved=0<https://feynarts.de/cuba/>>. -- Best regards, Ivan [[alternative HTML version deleted]]