[R] multidimensional integration with adapt

Helene
Mon, 05 Nov 2007 03:32:05 -0000

Hello,



I apologize for eventual double-posting.



I am trying to integrate a 2-dimensional function that already calls the
function adapt. More precisely, I am calling



adapt(2,lower=c(-100,-100),upper=c(100,100),functn=function(s){1-exp(-50*Unc
enteredGauss(c(-10,10,-10,10),60,s)})



where UncenteredGauss is given by the following code in R:



UncenteredGauss=function(limsamp,sigma2,s)

{

int=adapt(2,lower=c(limsamp[1],limsamp[3]),upper=c(limsamp[2],limsamp[4]),fu
nctn=function(u){h(sigma2,s,u)})

value=int$value

return(value)

}

h=function(sigma2,s,u){1/(2*pi*sigma2)*exp(-((u[1]-s[1])^2+(u[2]-s[2])^2)/(2
*sigma2))}



This does not return an error message but a value that is not the good one.

UncenteredGauss gives the good result, but I believe the problem comes from
calling in adapt a function that already calls adapt

Any idea on how to integrate a function that already contains an integral???



Thanks!



Helene Morlon

Green Lab

Center for Ecology and Evolutionary Biology

University of Oregon, Eugene

morlon.helene@gmail.com




	[[alternative HTML version deleted]]