Keep It Simple, Stupid | |
PerlMonks |
Re: Sampling From a Histogram Distributionby educated_foo (Vicar) |
on Jan 06, 2014 at 00:53 UTC ( [id://1069437]=note: print w/replies, xml ) | Need Help?? |
Assume you have a uniform random number generator, like Perl's rand. Just scale its output to the range 1..(4+19+10+5), then assign each of your four things a suitably-sized chunk of that range (apples == 1..4, oranges == 5..24, etc.).
In Section
Seekers of Perl Wisdom
|
|