[R] Precision in estimating log

2006-05-19 Thread Gichangi, Anthony
Hi R-users, I have the following code: f -function(x,p)sqrt(-(x^2)-2*log(1-p)) r1 -sqrt(-2*log(1-0.95)) r2 -sqrt(-2*log(0.05)) on executing i get the following results f(r1,0.95) [1] 0 f(r2,0.95) [1] NaN Warning message: NaNs produced in: sqrt(-(x^2) - 2 * log(1 - p)) I tried to track

Re: [R] Precision in estimating log

2006-05-19 Thread Sean O'Riordain
Anthony, in the same way that we're not allowed to say if(x==0) if x is a real number, we can't say that 0.05=1-0.95... as 1-0.95 is not represented as a base 10 number on the computer, but in some base 2^i depending on your computer...and the representation is not necessarily exact... i.e.

Re: [R] Precision in estimating log

2006-05-19 Thread Duncan Murdoch
On 5/19/2006 8:25 AM, Gichangi, Anthony wrote: Hi R-users, I have the following code: f -function(x,p)sqrt(-(x^2)-2*log(1-p)) r1 -sqrt(-2*log(1-0.95)) r2 -sqrt(-2*log(0.05)) on executing i get the following results f(r1,0.95) [1] 0 f(r2,0.95) [1] NaN Warning message: NaNs

Re: [R] Precision in estimating log

2006-05-19 Thread Ingmar Visser
] Precision in estimating log Hi R-users, I have the following code: f -function(x,p)sqrt(-(x^2)-2*log(1-p)) r1 -sqrt(-2*log(1-0.95)) r2 -sqrt(-2*log(0.05)) on executing i get the following results f(r1,0.95) [1] 0 f(r2,0.95) [1] NaN Warning message: NaNs produced in: sqrt(-(x^2