01 July 2011

Maximums and Minimums of Dice Rolls

A week month a while back I received questions from Christian and a read post from Saxywolf on essentially the same question: What is the probability of rolling a given value on an D-sided die, if you roll N dice and take the highest (or the lowest).

Here's the trick:
The probability of rolling a 1 on 1 d6 is 1/6. (regular 6-sided dice)

For 2d6 the probability of rolling a 1 as the maximum is 1/6 times 1/6, or 1/(6*6) = 1/36.
For Nd6 the probability of rolling a 1 as the maximum is 1/6 times itself N times, or (1/6)^N.

For D-sided dice just substitute D for 6 above, so that the probability of rolling a 1 as the maximum of N D-sided dice is 1/D times itself N times, or (1/D)^N.

Now consider the problem of rolling 2-or less as the maximum. The probability of rolling 2-or-less is 2/D, and the probability of rolling a  2-or-less as the maximum is 2/D times itself N times, or (2/D)^N.
That's 2-or-less, but we really just want the probability of rolling 2, not 1 or 2.  BUT we already know the probability of rolling a 1 as the maximum on the same dice, so we can subtract that to get what we want:

The probability of rolling a 2 as the maximum is 2/D times itself N times, minus the probability of rolling 1 as the maximum, or (2/D)^N - (1/D)^N.

And that's it. Using the same math you can work the complete distribution of the maximum for any number of dice with any number of (equally likely) faces. Just start at 1 and work up. For minimums, just turn the problem around and find the probability of X-or-less.

Still too much math? Fear not for there is a spreadsheet to do the calculations for you:
 Link to Google Docs Spreadsheet

See the blue numbers in the green-shaded cells? Change those to the number of side on your dice and the number you want to roll, and it will calculate the distribution for you. It might even work inside the blog?Nope, but it was worth a try. The spreadsheet is now public and can be edited at the link above (also downloaded). Changes made there WILL show up here when the page is reloaded, which means you are looking at whatever was most recently entered.



And a chart to display the results:





This is a bit of an experiment, both linking to a shared spreadsheet, and adding the HTML code to it directly inside my blog post. One upshot of this is that when one person changes the spreadsheet, it will change it for everyone. Play nice! Let me know if it works too. [Fixed!]
Post a Comment