lundi 6 février 2017

Generating a number of random choices (from a set of choices) with probability associated to each of the choice [duplicate]

This question already has an answer here:

I have a set of choices say (a,b,c) with their probability (0.3,0.6,0.1) respectively and I want to generate 100 random choices such that out of 100 , 30 choices should be "a" ,60 should be "b" and 10 should be "c" . I don't want to brute force and generate first 30 choices as "a" and so on.

More like I have 100 data values which I want to categorise in these 3 choices, it should be such that 30% of the data values have been categorised in "a" and so on.

Any prog language is accepted but python would be appreciated.




Aucun commentaire:

Enregistrer un commentaire