Doran, Harold wrote:
>
> I am trying to use the adapt function in the package adapt. To make sure
> I am using it correctly, I am trying a toy example that should yield a
> result of 2/3.
>
> Suppose the function is f(x,y) = x*y^2 and I want to integrate over f as
>
> Int_0^1 Int_0^2 x*y^2 dxdy
>
> Where the limits of integration for y are 0 to 1 and the limits for x
> are 0 to 2. So, I tried
>
> ff <- function(xy) x*y^2
> adapt(2, lo = c(0,0), up = c(1,2), fun = ff)
>
> And this produces
>
>> adapt(2, lo = c(0,0), up = c(1,2), fun = ff)
> value relerr minpts lenwrk ifail
> 2 7.38275e-08 165 73 0
>
> Can anyone offer insight into my error?
>
> Harold
>
adapt() wants a function whose first argument is a vector of parameters
(and you had your limits switched, I think).
> ff <- function(p) p[1]*p[2]^2
> adapt(2,lo=c(0,0),up=c(2,1),fun=ff)
value relerr minpts lenwrk ifail
0.6666667 7.142849e-08 165 73 0
--
View this message in context:
http://www.nabble.com/Adapt-function-tp25808121p25808382.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
R-help@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.