[R] puzzle with integrate over infinite range

baptiste auguie baptiste.auguie at googlemail.com
Tue Sep 21 19:29:04 CEST 2010

I see, thank you.

I'm still worried by the very dramatic error I obtained just from
shifting so slightly the support of the integrand, it took me a while
to figure what happened even with this basic example (I knew the
integral couldn't be so small!).

For a general integration in [0, infty), there must be a link between
the number of quadrature points, the transformation applied to the
integrand, and the region (position, width) where the measurable
integrand needs to be in order to be sampled by the quadrature. I
guess this kind of info lies deep inside the source code though.



On 21 September 2010 19:00, Thomas Lumley <tlumley at u.washington.edu> wrote:
> On Tue, 21 Sep 2010, baptiste Auguié wrote:
>> Thanks, I'll do that too from now on.
>> It strikes me that in a case such as this one it may be safer to use a
>> truncated, finite interval around the region where the integrand is
>> non-zero, rather than following the advice of ?integrate to use Inf as
>> integration limit. At least one wouldn't risk to get an entirely wrong
>> result depending on a choice of rel.tol. Regarding this parameter, is there
>> a simple interpretation of how it affected the result in the context of my
>> example?
> Not really.
> If you know where the integrand is non-zero then you can shift it so that
> integrate() can handle it.  If you don't know then you can't get the
> truncated interval right.
> The truncation approach works well for the Normal density because it it is
> non-negative, symmetric, and has nearly bounded support. The truncation
> error goes down extremely fast and if the mode of the density is in the
> center of the interval then all the mass can easily be found.   If you have
> a function with multiple modes and heavier tails it is harder to get an
> interval that is large enough to make the truncation error small, and still
> allows the integrate() function to find all the mass.
>    -thomas
> Thomas Lumley
> Professor of Biostatistics
> University of Washington, Seattle


Dr. Baptiste Auguié

Departamento de Química Física,
Universidade de Vigo,
Campus Universitario, 36310, Vigo, Spain

tel: +34 9868 18617

More information about the R-help mailing list