Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Re: Rolling a biased die

by tomazos (Deacon)
on Apr 13, 2002 at 14:38 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://158780]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-04-16 21:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found