[R] integrate function
Richard Condit
condit at ctfs.si.edu
Thu Mar 7 20:47:03 CET 2002
After finding an error in R's integrate function, I spent some time testing
various alternative numerical integration routines I took from the
Numerical Recipes book by Press et al. Here is a brief summary of what I found.
As near as I can tell, no method for numerical integration is foolproof. I
believe that no matter the method, functions could be invented to defeat
it. In particular, as Ole Christensen pointed out, if a function has
positive values only in a very narrow range, then numerical routines cannot
be guaranteed to find it.
R's integrate function works better more often than the alternatives I
tested. It succeeded with some very tricky functions that foiled the other
methods. But it did fail in some circumstances.
My only advice about the R integrate function would be to point out in
documentation that the value returned as "abs error" is not in fact the
error. There is no way I found of calculating the deviation between a
numerical estimate of an integral and the true integral. Abs error is
simply the change in the estimate between the last 2 iterations of the
numerical routine. In many cases, this should be a rough approximation of
the discrepancy between estimate and true integral, but if integrate fails,
abs error fails too. I would suggest abs error not even be returned with
the estimate of the integral, since it doesn't add information (since
abs.tol is set in the function).
I can provide more information about the various methods and their errors,
if anyone is interested.
Rick
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list