Given a vector p
of probabilities, what is a fast way to generate a random boolean vector x
of same length as p
and with independent elements such that x[i]==TRUE
with probability p[i]
for every i
?
Specifically, is there a faster way than runif(length(p)) < p
?
Aucun commentaire:
Enregistrer un commentaire