My code above would work nicely since your 5 samples would use the same weighting and so you get the speed win. Build a tiny wrapper to call it 5 times.
For Example:
sub lots_o_indexes { my($count)=@_; my @indexlist; foreach (1..$count) { push @indexlist, weighted_rand(@weights); } return @indexlist; }
In reply to Re: Re: Weighted random numbers generator
by dga
in thread Weighted random numbers generator
by spurperl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |