[R] optimizing code
Carl Witthoft
carl at witthoft.com
Thu Oct 10 13:45:18 CEST 2013
FMRPROG wrote
> I am generating random numbers from a normal distribution using
> [snip]
>
> I need to optimize the speed WITHOUT using the rnorm function but have no
> idea how to do this. I assume I should minimise what goes in the loop?
>
> Any help would be very much appreciated.
Looks like homework.
Thus, only a hint: any time you create something one at a time with a loop,
you almost certainly can create all "n" values by taking advantage of R's
built-in vectorization. Every statement in your loops can be vectorized.
--
View this message in context: http://r.789695.n4.nabble.com/optimizing-code-tp4677966p4677972.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list