Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: weighted biased dice roll

by ikegami (Pope)
on Aug 05, 2014 at 17:37 UTC ( #1096323=note: print w/replies, xml ) Need Help??


in reply to weighted biased dice roll

[No longer applies]

The code you posted doesn't compile. Once that's fixed, it still doesn't work. Because all of weights are larger than the maximum value returned by rand (slightly less than one), It always prints the first value returned by each.

Replies are listed 'Best First'.
Re^2: weighted biased dice roll
by sys0p (Novice) on Aug 05, 2014 at 17:42 UTC
    I've just figured it out. And updated the question to a compiling state. Thank you anyways! The problem was misinterpretation of the weights.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1096323]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2018-06-24 07:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (126 votes). Check out past polls.

    Notices?