On Sun, 13 Feb 2000, Kjetil Kjernsmo wrote:
> Dear all,
>
> I'm a bit concerned about underflow problems. Such problems typically
> occur when two almost equal numbers are subtracted. I was wondering if R
> has any mechanisms for warning users about potential problems, or if any
> policy has been developed?
>
> To check, I just did:
> > 1.0000000000000001 - 1
> [1] 0
> > 1.000000000000001 - 1
> [1] 1.110223e-15
> > 1.00000000000001 - 1
> [1] 9.992007e-15
>
> I guess many users are unaware of the potential problems caused by
> underflow (i.e. garbage becoming significant), so perhaps R should issue
> a warning?
Checking for loss of precision would be a) hard, b) slow, c) probably
unreliable. We do provide the Machine() function that returns information
about the level of precision being used.
In your first example, you would find that 1.0000000000000001 is equal to
1 up to machine precision
R> 1.0000000000000001
[1] 1
The reason that testing is hard and unreliable is that there is very
little absolute loss of precision in the arithmetic operations. There can
be enormous relative loss of precision, but that depends critically on how
big the correct final answer is.
Eg
exp(1.0000000000000001-1)
or
2+(1.0000000000000001-1)
have essentially full precision.
A bigger issue, which we _have_ been working on, is getting closer to full
precision for the probability and quantile functions.
-thomas
Thomas Lumley
Assistant Professor, Biostatistics
University of Washington, Seattle
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._