jeudi 23 juillet 2015

At least one integer equal to one in creating a uniform random distribution

I have created a string of integers taking the value 0 or 1 with a uniform random distribution.

s <- floor(runif(7, min=0, max=2))

Because it is random, it could be that all values of the vector s are 0.

But I would like at least one of the integers to take the value 1.

Does anyone know how to do that?




Aucun commentaire:

Enregistrer un commentaire