Following on from this q (Cannot understand why random number algorithms give different results), I have some code simulating random booleans. Because I wish to do this ALOT and fast, I wish to wrap this in a function like so:
# setup external to function
number <- 5
probs <- rep(0.1, 5)
# core function
event.sim <- function(var, things){
mod.probs <- probs * var
events <- matrix( rbinom(things*number, 1, probs), ncol=number, byrow=FALSE)
av.events <- max(rowMeans(events))
return(av.events)
}
event.sim(var=50, things=1000)
and parallelize it using library("parallel") clusterMap(). Now this is no problem and I have this working, however I am concerned that by executing in parallel, my booleans are not sufficiently "random" anymore. I can find alot of info online about generating random numbers in parallel, but they all seem to describe generating lots of random numbers at once, and I can't relate that to my function that draws relatively few random booleans each time it is run. Have I problem here and do I need to do something differently ?
Aucun commentaire:
Enregistrer un commentaire