[R] cuhre usage ?? multidimensional integration

R. Michael Weylandt michael.weylandt at gmail.com
Sat Oct 8 19:25:09 CEST 2011


I'd heartily suggest you read some basic R references before trying to
engage this question: a cursory glance over your code suggests it can
(and should) be entirely rewritten without for loops using
vectorization and possibly a product function like this one that I'll
provide you with:

product <- function(x) exp(sum(log(x)))

I'd do it myself, but to be honest, I don't really understand how its
supposed to work. What is the point of "looping" from 1 to 1 so many
times?

As to your question, your first error comes from trying to apply
multivariate integration techniques to a function of a single
variable. Specifically, you give R secondary and (possibly) tertiary
arguments and tell it to hand them to a univariate function -- hence
the error. Your second error is probably caused by the fact that you
now have a function of four variables -- x,g, i, j -- where i is never
used other than the iterator (and you can't trick R so don't even go
down that path), g is overwritten before being accessed, and j just
doesn't appear at all.

Michael

On Wed, Oct 5, 2011 at 5:07 PM, sevenfrost <linshuang11 at gmail.com> wrote:
> cuhre is a function in package R2Cuba for multidimensional integration.
>
> There are three kind of variables to integrate. I just use y,w,t to
> distinguish them from each other. Is there any problem ?
>
> --
> View this message in context: http://r.789695.n4.nabble.com/cuhre-usage-multidimensional-integration-tp3873478p3876182.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.
>



More information about the R-help mailing list