mpalmer
2017-11-22 07:44:39 UTC
In a lot of projects I'm dealing with outcomes of variable probabilities. Say
A = .3
B = .1
C = .6
Up to now I set up a 100-size array and distribute the values 1-30 = A, 31-40 = B, and 41-100 = C, and then use a random generator to tell me which value should be selected. Is there an easier/more efficient way to do this?
A = .3
B = .1
C = .6
Up to now I set up a 100-size array and distribute the values 1-30 = A, 31-40 = B, and 41-100 = C, and then use a random generator to tell me which value should be selected. Is there an easier/more efficient way to do this?