$my $total=0; for( @$cats ){ my $p = $hash->{$_}; $cat = $_ if( rand($total+=$p)<$p ); } return $cat;
In reply to Re: Per cents and Probabilities
by I0
in thread Per cents and Probabilities
by dimmesdale
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |