how does one numerically intergate the following: A=function(x,y) { xy } over the range: 2<x<0 4<y<10 say. ie how would one set up the integrate function? i forgot!
Hi Allan you need adapt() from the adapt package. > library(adapt) > ?adapt > adapt(2,lower=c(-2,4),upper=c(0,10),functn=function(z){prod(z)}) value relerr minpts lenwrk ifail -84 7.38275e-08 165 73 0 > NB: untested HTH rksh On 5 Sep 2005, at 10:59, Clark Allan wrote:> > > how does one numerically intergate the following: > > A=function(x,y) > { > xy > } > > over the range: 2<x<0 4<y<10 > > say. > > > ie how would one set up the integrate function? > > i forgot!______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting- > guide.html-- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743
found a solution: download the rmutil package from : http://popgen0146uns50.unimaas.nl/~jlindsey/rcode.html for those that are interested. note that only works for two dimensions! / allan (ranges was incorrect previously: should be:-2<x<0 4<y<10) Clark Allan wrote:> > i solved the problem: > > adapt(2, lo=c(2,4), up=c(0,10)) > > is there any package that allows one to have infinite limits?? when > integrating over more than one variable? > > Clark Allan wrote: > > > > how does one numerically intergate the following: > > > > A=function(x,y) > > { > > xy > > } > > > > over the range: 2<x<0 4<y<10 > > > > say. > > > > ie how would one set up the integrate function? > > > > i forgot! > > > > ------------------------------------------------------------------------ > > ______________________________________________ > > R-help at stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
On 9/5/05, Clark Allan <Allan at stats.uct.ac.za> wrote:> > > how does one numerically intergate the following: > > A=function(x,y) > { > xy > } > > over the range: 2<x<0 4<y<10 > > say. > > > ie how would one set up the integrate function? > > i forgot! >In this particular case its separable so you could just integrate each factor and multiply the two results but if you want to do it in terms of A then see: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/43836.html