[Rd] 0.5 != integrate(dnorm,0,20000) = 0

Stavros Macrakis macrakis at alum.mit.edu
Tue Dec 14 01:52:49 CET 2010


I'd suggest that the original sin here is calling some particular
numerical integration routine 'integrate', which gives the user an
illusory sense of power.... Functions have to be well-behaved in
various ways for quadrature to work well, and you've got to expect
things like

> integrate(function(x)tan(x),0,pi)
Error in integrate(function(x) tan(x), 0, pi) :
  roundoff error is detected in the extrapolation table   <<< a 'good'
error -- tells the user something's wrong
> integrate(function(x)tan(x)^2,0,pi)
1751.054 with absolute error < 0                                  <<< oops
> integrate(function(x)1/(x-pi/2)^2,0,pi)                         <<< the same pole (analytically)
Error in integrate(function(x) 1/(x - pi/2)^2, 0, pi) :         <<<
gets a useful error in this form
  non-finite function value

But by that argument, I suppose you shouldn't call floating-point
addition "+" :-)

                -s



More information about the R-devel mailing list