in reply to Rolling a biased die
my %bias = ( 1 => 3.1, 2 => 2.0234, 3 => 1.7, 4 => 1.542232, 5 => 1.321249563, 6 => 1.0142, ); my $sum = 0; while( my($k,$v) = each %bias ){ $rand = $k if rand($sum+=$v) < $v; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Rolling a biased die
by tommyw (Hermit) on Apr 12, 2002 at 11:32 UTC | |
Re: Re: Rolling a biased die
by ferrency (Deacon) on Apr 12, 2002 at 13:39 UTC | |
Re: Re: Rolling a biased die
by tomazos (Deacon) on Apr 13, 2002 at 13:56 UTC | |
Re: Re: Rolling a biased die
by tomazos (Deacon) on Apr 13, 2002 at 14:38 UTC |
In Section
Seekers of Perl Wisdom