Skip to content
Back to formatted view

Raw Message

Message-ID: <CA0BCF3BED56294AB91E3AD74B849FD503B9313D@us-arlington-0668.mail.saic.com>
Date: 2005-09-22T17:41:18Z
From: Tuszynski, Jaroslaw W.
Subject: how to keep very small or large number?

R can hold very small numbers. It is the round-off error during addition
(and other basic operations) that causes the problem. For example:
> x=1e-300
> x
[1] 1e-300
> (x+1)-1
[1] 0

If you need a code that can be immune to round-off problems - you need to
write it yourself (please correct me if I am wrong). At some point I needed
'sum' and 'cumsum' that would not have that problem and I end up writing my
own versions of those functions. See examples of 'sum.exact' and
'cumsum.exact' in 'caTools' package. 

Jarek Tuszynski

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] 
Sent: Thursday, September 22, 2005 12:53 PM
To: r-help at stat.math.ethz.ch
Subject: [R] how to keep very small or large number?

When I was computing some joint probabilities, I found that R reported most
of the results to to -Inf and thus didn't record the value. I guess it is
b/c the joint log(probability) can be extremely small. Is there a way in R
to keep the values even if they are small?

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html