Ok so I need to make a random boolean based on prior probabilities that I've calculated beforehand. Currently I am doing something like this:
sample(0:1,1,replace=T, c( 0.6, 0.4))
This works just fine of course, the problem is I need to do this millions of times (based on different weights each time - 0.6,0.4 simple an example). Of course I have wrapped it in sapply and have parallelized it and it works, but I may need to ramp this up to tens of millions or more and I was wondering is there a quicker way to generate a weighted random boolean than the sample() command
Aucun commentaire:
Enregistrer un commentaire