[R] problems with rexp ?

David Hunter dhunter at stat.psu.edu
Fri May 3 19:14:17 CEST 2002

On Fri, 3 May 2002, Juan Ramon Gonzalez wrote:

> Does anyone know if R have any problems with the exponential random number
> generation (function rexp)?
> I comment it because I executed
> data<-sort(rexp(100))
> plot(data,dexp(data)/(1-pexp(data)),type="l")
> and the graphic isn't constant.

Hi.  Note that dexp(data)/(1-pexp(data)) is exactly (theoretically) 1
regardless of the values of 'data'.  Thus, the nonconstant plot you're
getting is solely due to roundoff (cancellation) error and gives no
information about the distribution of the 'data' vector except that it
contains some positive values for which the exponential density is very
small. (Hence there's no indication of any problem with rexp).

David Hunter
Assistant Professor of Statistics
Penn State University
dhunter at stat.psu.edu
(814) 863-0979

r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list