I need help creating a general function or pseudocode that chooses a single event from a group events who all have different probabilities. Ex.
- event 1 = 45%
- event 2 = 15%
- event 3 = 50%
- event 4 = 35%
- event 5 = 50%
I need help creating a general function or pseudocode that chooses a single event from a group events who all have different probabilities. Ex.
The simplest solution would be to sum and normalize the ranges (as an example, the sum of the values is 195, your first event would get the range [0, 45/195=0.23[, the second one [0.23, 0.23+0.076=0.31], and so on), then extract a number from [0,1[ and look to what range it belongs.