I wrote "replicate" but the darn e-mail program "fixed" it for me.  I expected 
replicate to be a bit slower, but not by that amount.  I just wanted to include 
replicate as a more readable version of lapply while still improving over the 
loop approach.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -----Original Message-----
> From: Ben Bolker [mailto:bol...@ufl.edu]
> Sent: Friday, May 15, 2009 10:19 AM
> To: Greg Snow
> Cc: r-help@r-project.org
> Subject: Re: [R] Simulation
> 
> 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
> bol...@ufl.edu / www.zoology.ufl.edu/bolker
> GPG key: www.zoology.ufl.edu/bolker/benbolker-publickey.asc

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to