PPBA
PPBA copied to clipboard
Hello! I would like to know why 115 lines, 116 lines let the ‘probability’ compare with ‘r’?

Hi, Kitzzaaa. Let us assume the probabilities of three situations should be: 0.2:0.3:0.5. We can sample a value r from [0,1]. If r is in [0, 0.2], it should be the first situation. If r is in (0.2, 0.2+0.3=0.5], it should be the 2nd one. And if r is in (0.5, 0.5+0.5=1], it should be the 3rd one.
For get_probability, we get the partition for three situations (like 0.2:0.3:0.5). Then r is the value randomly sampled from [0,1]. And we make the decision as above.