Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Re: Rolling a biased die

by tomazos (Deacon)
on Apr 13, 2002 at 14:38 UTC ( #158780=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my $sum = 0;
    $biasbase{$_} = ($sum += $bias{$_}) foreach (reverse keys %bias);
    
  2. or download this
    while( my($k,$v) = each %bias and not defined $rand){
        $rand = $k if rand($biasbase{$k}) < $v;
    }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://158780]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2019-10-13 22:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?