lundi 4 mai 2015

Biased random number sequence generator [duplicate]

This question already has an answer here:

How would I generate biased random number sequence between [1-4] of length 20 in python?

When I said bias what I meant is that ,for example, I would like to see numbers 1 and 2 appear 40% of the time in the my randomly generated sequences.

For example, 20(sequence length)x 40%(bias) = 8. Therefore, my random generator assigns 8 (1's or 2's) and the rest 60% (remaining 12 numbers) will be 3's and 4's.

Final sequence might look like this: 23112134333244344241

There is no priority on how these numbers appear in the sequence. As long as it follows the bias we introduced, we are fine.




Aucun commentaire:

Enregistrer un commentaire