Help for this page

Select Code to Download


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