This is what numerical integration functions are like, unfortunately. 
That's why the help page says:
  "Like all numerical integration routines, these evaluate the function on a
   finite set of points. If the function is approximately constant (in
   particular, zero) over nearly all its range it is possible that the
   result and error estimate may be seriously wrong."

If you know anything about where the function has jumps you can use this 
knowledge to pick better intervals.  Changing the subdvisions argument has 
no effect, since this is the *maximum* number, not the minimum number.

I don't think we know of numerical quadrature routines that are uniformly 
better than these and GPL-compatible.

        -thomas


On Thu, 8 Mar 2007, [EMAIL PROTECTED] wrote:

> Full_Name: Bert De Boeck
> Version: R 2.2.0
> OS: Windows
> Submission from: (NULL) (157.193.193.152)
>
>
> I think there is a bug when using integrate for integrating a function which 
> is
> 0 in a whole sub-interval. For example:
>
> #define uniform function
> f<-function(x){ifelse(x<1,0,ifelse(x<3,1,0))}
>
> #this is the correct integral
> integrate(f,-10,10)
>
> #here there is a problem
> integrate(f,-50,50)
> integrate(f,-10,50)
> integrate(f,-50,10)
> integrate(f,-50,50,sub=10000)
>
> # I noticed this for a more complex function, but as you see even for a 
> trivial
>
> # function there is a serious problem
>
> ______________________________________________
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

Thomas Lumley                   Assoc. Professor, Biostatistics
[EMAIL PROTECTED]       University of Washington, Seattle

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to