[R] Simulation

Ben Bolker bolker at ufl.edu
Fri May 15 18:19:05 CEST 2009

Greg Snow wrote:
> Another possibility (maybe more readable, gives the option of a list, probably not faster):
> Replicate(1000, rexp(15,1) )

  I think that should be "replicate"

  The matrix form is quite a bit faster, but don't know if that will
matter -- times below are for doing this task (1000 x 15 replicates)
1000 times ...

> system.time(replicate(1000,replicate(1000,rexp(15,1))))
   user  system elapsed
 12.689   0.220  12.985
> system.time(replicate(1000,matrix(rexp(15000,1),ncol=15)))
   user  system elapsed
  2.512   0.452   2.976

Ben Bolker
Associate professor, Biology Dep't, Univ. of Florida
bolker at ufl.edu / www.zoology.ufl.edu/bolker
GPG key: www.zoology.ufl.edu/bolker/benbolker-publickey.asc

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090515/dadc58e8/attachment-0002.bin>

More information about the R-help mailing list