search for: currentdeck

Displaying 1 result from an estimated 1 matches for "currentdeck".

2012 Jun 15
2
Looking for Speed in a Toy Simulation Example
...############################### ## Initialize matrix to hold results singlecolor <- matrix(NA, simlength, noplayer) ## construct the deck to sample from basedeck <- rep(1:4, 13) ## This one uses split to create the individual hands set.seed(7777) system.time({ for (i in 1:simlength) { currentdeck <- split(sample(basedeck, decklength), rep(1:noplayer, 5)) singlecolor[i, ] <- sapply(currentdeck, function(inv) { length(unique(inv)) == 1 }) } }) apply(singlecolor, 2, mean) mean(apply(singlecolor, 2, mean)) ################################################# ## Variant 2...