Displaying 1 result from an estimated 1 matches for "sampledeck".
Did you mean:
sampledec
2012 Jun 15
2
Looking for Speed in a Toy Simulation Example
...trix to hold results
singlecolor <- matrix(NA, simlength, noplayer)
## construct the deck to sample from
basedeck <- rep(10^(1:4), 13)
## This one uses matrix(...,5) to create the individual hands
## comparison by using powers of ten
set.seed(7777)
system.time({
for (i in 1:simlength) {
sampledeck <- sample(basedeck, decklength)
currentdeck <- matrix(sampledeck, nrow = 5)
singlecolor[i, ] <- apply(currentdeck, 2, function(inv) {
any(sum(inv) == (5 * 10^(1:4))) })
}
})
apply(singlecolor, 2, mean)
mean(apply(singlecolor, 2, mean))
#############################################...