On Fri, May 06, 2011 at 11:49:30AM -0700, Megh Dal wrote:
> Hi all, I am to find some way on how I can tell R to use this small number 
> 10^-20 as zero by default. This means if any number is below this then that 
> should be treated as negative, or if I divide something by any number less 
> than that (in absolute term) then, Inf will be displayed etc.
> 
> I have gone?through?the help page of options() function, however could not 
> find anything on how to handle that issue. Can somebody help me on this 
> regards?

Hi.

If you define your own classes of objects, then this can be done
in your own R code. This can work also in some other R code, but
not in the calls of the compiled functions, which are frequent in R
for speed. For example, it will not work in sum(x), mean(x), sqrt(x)
unless you prepare your own versions of these functions.

I am not sure, what is the exact definition of a negative number
in your arithmetic. Since 10^-30 < 10^-20, should 10^-30 be
treated as negative? Then, what is 1/(10^-30)?

If you need the modification for a concrete application, then it is
better to design a specialized algorithm for your application, which
uses the standard arithmetic and includes explicit tests like
abs(x) < 1e-20.

Petr Savicky.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to