"be consistent" PerlMonks

### Re: Re: Rolling a biased die

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

in reply to Re: Rolling a biased die
in thread Rolling a biased die

Cool algorithm. It's like a king of the hill match.

1 starts as king of the hill. (\$rand = 1)

2 comes along and challanges it. Whoever wins stays on top (is assigned to \$rand).

Just like 2, everyone else (3, 4, 5 and 6) gets a chance.

Whoever is left on top (\$rand) is declared the winner. :)

To understand why the probabilities work you have to step through the algorithm backwards.

ie. What is the chance that 6 (the final iteration) is going to win it's match against the king of the hill? \$bias{6} / sum(values %bias), which is obvious.

Now - consider the second last iteration (5). Given that 6 is going to have it's chance in a minute, and hence does not need to be included, what is the chance that 5 will win it's match? \$bias{5} / (sum(values %bias) - \$bias{6}). We remove 6 from the running by excluding it's weighting from the total.

Update: This explanation is awful. :)

Create A New User
Node Status?
node history
Node Type: note [id://158773]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2019-10-13 22:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
In 2019 the site I miss most is:

Results (36 votes). Check out past polls.

Notices?