From baptiste.auguie at googlemail.com  Tue Dec  7 09:07:56 2010
From: baptiste.auguie at googlemail.com (baptiste auguie)
Date: Tue, 7 Dec 2010 09:07:56 +0100
Subject: [Rd] 0.5 != integrate(dnorm,0,20000) = 0
In-Reply-To: <4CFD729C.6050704@structuremonitoring.com>
References: <4CFD729C.6050704@structuremonitoring.com>
Message-ID: <AANLkTikzd5j2dG97FWNMxcJCm3MwfRjAs4y8X-pgmhnA@mail.gmail.com>

Hi,

I was recently given some interesting tips on a similar issue, see
R-help "puzzle with integrate over infinite range"
<http://www.r-help.com/list/85/713882.html>

Maybe "fails" can be a bit misleading here (fails to produce the
actual result vs. returning an error message). As a result of this
previous discussion, I don't think it would be possible to return an
error: as far as the algorithm knows, the value it calculated is 0
because the integrand was 0 everywhere. To know better, the program
would need to sample the integrand at more points (which can be
achieved by changing the interval, or better, by setting the tolerance
to a lower value).

baptiste



On 7 December 2010 00:32, Spencer Graves
<spencer.graves at structuremonitoring.com> wrote:
> Hello:
>
>
> ? ? ?The example "integrate(dnorm,0,20000)" says it "fails on many systems".
> ?I just got 0 from it, when I should have gotten either an error or
> something close to 0.5. ?I got this with R 2.12.0 under both Windows
> Vista_x64 and Linux (Fedora 13); ?see the results from Windows below. ?I
> thought you might want to know.
>
>
> ? ? ?Thanks for all your work in creating and maintaining R.
>
>
> ? ? ?Best Wishes,
> ? ? ?Spencer Graves
> ###############################
>
> integrate(dnorm,0,20000) ## fails on many systems
> 0 with absolute error < 0
>> sessionInfo()
> R version 2.12.0 (2010-10-15)
> Platform: i386-pc-mingw32/i386 (32-bit)
>
> locale:
> [1] LC_COLLATE=English_United States.1252
> [2] LC_CTYPE=English_United States.1252
> [3] LC_MONETARY=English_United States.1252
> [4] LC_NUMERIC=C
> [5] LC_TIME=English_United States.1252
>
> attached base packages:
> [1] stats ? ? graphics ?grDevices utils ? ? datasets ?methods ? base
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



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