[R] Adapt function
Doran, Harold
HDoran at air.org
Thu Oct 8 19:14:12 CEST 2009
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
> sessionInfo()
R version 2.9.0 (2009-04-17)
i386-pc-mingw32
locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
States.1252;LC_MONETARY=English_United
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] adapt_1.0-4
loaded via a namespace (and not attached):
[1] tools_2.9.0
More information about the R-help
mailing list