[R] [FORGED] Multiple Integrals
David Winsemius
dwinsemius at comcast.net
Thu Jan 7 08:33:14 CET 2016
> On Jan 6, 2016, at 8:37 PM, Rolf Turner <r.turner at auckland.ac.nz> wrote:
>
> On 07/01/16 13:03, Luísa Freitas wrote:
>> Dear R-helpers,
>>
>> I'm looking for a quick way to calculate triple integrals.
>>
>> I have tried something like this example:
>>
>> f <- function(x,y,z) dnorm(x)*dnorm(y)*dnorm(z)
>> llim <- -Inf
>> ulim <- Inf
>> integrate(function(z)
>> {
>> sapply(z,function(z)
>> {
>> integrate(function(y)
>> {
>> sapply(y, function(y)
>> {
>> integrate(function(x) f(x,y,z), llim, ulim)$value
>> })
>> }, llim, ulim)$value
>> })
>> },llim,ulim)
>>
>> I'm not sure if there are other ways faster than this one.
>> Any help will be appreciated.
>
> GIYF. Searching on "multiple integration r" led me very quickly to the R2Cuba package for multidimensional numerical integration, which will presumably do what you want. (I have not tried it out; that's your job.)
I have not tried that package out but I can report satisfactory experience with the r package 'cubature'.
--
David.
>
> cheers,
>
> Rolf Turner
>
> --
> Technical Editor ANZJS
> Department of Statistics
> University of Auckland
> Phone: +64-9-373-7599 ext. 88276
>
> ______________________________________________
> 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.
David Winsemius
Alameda, CA, USA
More information about the R-help
mailing list