- or download this
-log(1 - rand)/$weight
- or download this
my @matrix = ( [a => 0.1], [b => 0.5], [c => 0.4] );
my $chosen = pick(@matrix);
...
}
return $choice;
}
- or download this
use Math::Random::MT qw(rand);
- or download this
my %picked;
for(1 .. 1E5) {
...
}
use Data::Dumper;
print Dumper \%picked;
- or download this
$VAR1 = {
'c' => 40200,
'a' => 10042,
'b' => 49758
};