mardi 10 mars 2020

Generate binomial samples determining the probability

I want to generate n samples of binary values (0 or 1) randomly:

This is easy with runif:

samples <- round(runif(n,min=0, max=5))

But the probability of having 0 or 1 is 50%. But, what if I want to state a probability of for example 30% of having 1 and 70% of having 0?

I thank you a lot




Aucun commentaire:

Enregistrer un commentaire