I have a set of integers, each of which has a certain probability obtained from earlier experiments, for example:
0 = 0.5
1 = 0.2
2 = 0.3
According to the specifications of the probability distribution, these weights add up to 1.0. Now I'm looking for an effective way to select one of the values ββwhen taking these probabilities into account, for example. (Pseude code):
Distribution distribution = new CustomDistribution(new double[]{0.5, 0.3, 0.2});
distribution.sample();
This should result in half the time according to the given numbers. However, do not assume any patterns or patterns between them.
I used Apache Commons Math for my previous experiments, but it doesn't seem to provide a solution for this scenario, Colt .
, , . , . .