[R] Viewing function source

Thomas Lumley tlumley at u.washington.edu
Wed Aug 27 01:21:08 CEST 2003

On Tue, 26 Aug 2003 Ted.Harding at nessie.mcc.ac.uk wrote:

> Thomas Lumley wrote:
> > The name of this generator is descriptive, not a pun. It is very slow
> > for large lambda, and incorrect for extremely large lambda (and
> > possibly for extremely small lambda).
> Not sure why it should be incorrect. It's certainly not theoretically
> incorrect. Rounding errors? Problem with runif()?

Yes. Both.  But it should work as long as lambda is much smaller than
2^53 and much larger than 2^-32 and much smaller than the period of
whatever generator you are using, so it's going to be too slow before it's

> > If you only wanted a fairly small number of random variates with, say,
> > 1e-6<lambda<100, then it's not too bad.
> In the above vectorised form, if it's fast for n=1 it stays pretty fast
> for large n: try it with z<-rfishy(10000,5); even rfishy(100000,5) only
> takes a few seconds.

If you were going to implement in another language (which I thought was
the point) then vectorising won't help.  In R, yes.


More information about the R-help mailing list