Re: [R] Looking for Speed in a Toy Simulation Example

2012-06-15 Thread Rui Barradas
Hello, With Michael's sugestions (I keep forgeting package compiler) t0 <- system.time({ ... variant 3.b ... # ## Variant 3.c ## # install.packages("compiler") libra

Re: [R] Looking for Speed in a Toy Simulation Example

2012-06-15 Thread R. Michael Weylandt
On Fri, Jun 15, 2012 at 9:48 AM, R. Michael Weylandt wrote: > As of recent versions of R, you can actually go for what are > officially recognized as "ultimate speed" functions .rowSums() and > friends. Sorry, perhaps that wasn't totally clear. Regarding .rowSums() note that leading period. You p

Re: [R] Looking for Speed in a Toy Simulation Example

2012-06-15 Thread R. Michael Weylandt
As of recent versions of R, you can actually go for what are officially recognized as "ultimate speed" functions .rowSums() and friends. You might also use the compiler() package to byte-compile that inner loop. [The function going to sapply] It won't be massive, but perhaps another 3 or 4x Micha

Re: [R] Looking for Speed in a Toy Simulation Example

2012-06-15 Thread Simon Knos
Rui, thank you very much. I keep forgetting about the rowSum and friends. (precalculating the powers just slipped my attention). And, yes, a factor of will of course do. Do you see a further improvement in this case? Best, Simon On Fri, Jun 15, 2012 at 12:25 PM, Rui Barradas wrote: > Hello,

Re: [R] Looking for Speed in a Toy Simulation Example

2012-06-15 Thread Rui Barradas
Hello, Will a factor of 4 do? This is variant 3, revised. # ## Variant 3.b ## # ## Initialize matrix to hold results singlecolor <- matrix(NA, simlength, noplayer) #

[R] Looking for Speed in a Toy Simulation Example

2012-06-15 Thread Simon Knos
Dear List Members I used to play around with R to answer the following question by simulation (I am aware there is an easy explicit solution, but this is intended to serve as instructional example). Suppose you have a poker game with 6 players and a deck of 52 cards. Compute the empirical frequ