Probability randome number picker with lower prob of higher number
Answers
Answered by
2
Step-by-step explanation:
- Just thinking: another possibility is to get rid of the fractions by multiplying with a constant multiplier, and then build an array with the size of this multiplier. Multiplying by 10 you get
- P(1) = 2
- P(2) = 3
- P(3) = 5
- Then you create an array with the inverse values -- '1' goes into elements 1 and 2, '2' into 3 to 6, and so on:
- P = (1,1, 2,2,2, 3,3,3,3,3);
- and then you can pick a random element from this array instead.
Similar questions