mardi 26 juillet 2022

R sampling either 0 and 1 based on a vector of probabilities

I want to sample 10 numbers, either 0 or 1, with the following chances:

c(0.1989185, 0.2879522, 0.1142932, 0.3057067, 0.2056559, 0.1492126, 
0.2775737, 0.3332775, 0.9276861, 0.4373286)

The first number has a 0.1989185 chance of being 0, and the second has a 0.2879522 chance of being 0, etc.




Aucun commentaire:

Enregistrer un commentaire