Just wondering what type of algorithm this is,
or if there is an easier/more efficient way to go about this:
Say we are given a certain probability density, say
prob[] = {.1, .15, .25, .05, .45}
Group 1 - 10%
Group 2 - 15%
Group 3 - 25%
Group 4 - 5%
Group 5 - 45%
and a random number, (0,1),
ran = .853234
Insert into one of the 5 groups
if (ran <=prob[0]) selection = 1;
else if (ran <= prob[0]+prob[1]) selection = 2;
...
else if (ran <= prob[0]+prob[1]+...+prob[4]) selection = 5;
I am not very well-versed on random number generation