[R] Help with pexp( )

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Apr 11 21:35:58 CEST 2007


On Wed, 11 Apr 2007, Douglas Bates wrote:

> On 4/11/07, Jeann S <jeann_123 at hotmail.com> wrote:
>> Dear all,
>>
>> Sorry for bringing up an old issue:
>>
>>    >pexp(50, 0.5)
>>     [1] 1
>>
>> In some cases, pexp()  gives CDF=1. I read some discussion in 2002 saying it
>> has been patched. However it's not working in "R2.4.1Patched". Could anyone
>> help me out?
>
> And why is this a problem?  The cdf of an exponential distribution
> with rate = 0.5 evaluated at x = 50 is very close to 1.  If you want
> to find out exactly how close you could use
>
> pexp(50, rate = 0.5, lower.tail = FALSE)
>
> which gives an answer on the order of 10^(-11).

As does

> 1-pexp(50, 0.5)
[1] 1.388789e-11

It might be worth reminding people that printing rounds to (by default 7) 
a certain number of significant digits.  (Dr Bates' answer is more 
accurate of course.)


-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list