B
Bo Sun
hi,
I would like to code the following problem:
there are 4 events, and their happening probability is:
e1 with probability 0.5
e2 with probability 0.2
e3 with probability 0.2
e4 with probability 0.1
I want to use some random function generation function. when its return
value is [0. 0.5), I select e1, when it is [0.5, 0.75), I select e2..
My question is: which function should I use to generate [0, 0.5).. based
on the probability? How should I code this?
Many thanks,
Bo
I would like to code the following problem:
there are 4 events, and their happening probability is:
e1 with probability 0.5
e2 with probability 0.2
e3 with probability 0.2
e4 with probability 0.1
I want to use some random function generation function. when its return
value is [0. 0.5), I select e1, when it is [0.5, 0.75), I select e2..
My question is: which function should I use to generate [0, 0.5).. based
on the probability? How should I code this?
Many thanks,
Bo