I have a vector of probabilities. With the probabilities, I want to draw a sample between (0,1) for each probability.
For example, prob_of_one indicates that 1 is drawn ((1-prob_of_one) is the probability that 0 is drawn).
data.frame(prob_of_one = c(runif(100)),desire_column = NA)
How can I have 0 or 1 value by sampling without using for-loop?
Aucun commentaire:
Enregistrer un commentaire