Re: [R] Numerical precision problem

From: Thomas Lumley <tlumley_at_u.washington.edu>
Date: Fri, 21 Dec 2007 14:02:42 -0800 (PST)

On Fri, 21 Dec 2007, C.Rosa_at_lse.ac.uk wrote:

> Dear All,
>
>
>
> I have a numerical problem:
>
> R, as other statistical software, can tell the difference between very
> small numbers and 0, while apparently cannot distinguish a number close
> to 1 and 1. In the example below, is it possible to instruct R to
> recognize that q is different from 1?

No, since q is not different from 1.
>
>> q==1
>
> [1] TRUE
>

>
> The main problem I have is that I need to evaluate the inverse of the
> normal Cumulative Distribution Function near 1 (but not exactly 1) and
> the PC cannot recognize it.
>

Use the lower.tail= argument to qnorm (or just use the fact that the standard Normal is symmetric)

> p=.00000000000000000000000000000001
> p

[1] 1e-32
> qnorm(p,lower.tail=FALSE)

[1] 11.85613
> -qnorm(p)

[1] 11.85613
>

         -thomas



R-help_at_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. Received on Fri 21 Dec 2007 - 22:10:56 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 21 Dec 2007 - 22:30:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.