Probabilities of simple dice rolls
I want to take some time to talk about dice. We all know those small, typically symmetric, solid objects that we toss during gaming and gambling. For millennia, humanity has allowed fate to generate random outcomes by the throw of a dice. As popular as ever, it is worth taking a closer look at how dice behave by exploring the mathematics that describe them.
A single roll
Let’s start by thinking about the most familiar of situations, rolling a single 6-sided dice, with either numbers or pips indicating the value of a face. There’s not too much to say here, if the dice is fair, then each side shows up with probability . So, what’s the probability of getting a 6? 1-in-6. How about the probability of getting a 5 or 6? We just add together the two probabilities to find , or 1-in-3. Pretty simple.
While the 6-sided dice (or d6) is the most common, plenty of other dice appear in other contexts, such as the Dungeons and Dragons linchpin: the 20-sided dice (or d20). Instead of going down the list of possible numbers of sides for a dice, let’s just take the general case and say we have an -sided dice. As for the 6-sided dice, the probability of any one side showing after a roll is . We can formalize our notion of dice roll outcomes a bit by letting represent the outcome of a roll as a random variable. If our dice is -sided, then can take on values , each with probability . We can summarize this by writing:
The notation on the left says that is distributed according to the dice roll distribution with sides (we could call it the discrete uniform distribution with endpoints 1 and , but I think “dice roll” more clearly describes what it is). The right-hand side defines the probability mass function (PMF) of the distribution — giving the probability that a specific face appears when rolling. Explicitly stating that the probability is zero outside of bounds of the dice is not really necessary, but gives a well-defined answer to questions like: “what is the probability of rolling a 7 on a 6-sided dice?” (it’s zero).
Working with the PMF is great, because any conclusions we draw from using it will be true for dice of any number of sides, we just substitute in a value for . One simple and useful result is to calculate , the probability that a dice roll is less than or equal to a given value, . This follows pretty simply from the PMF:
This expression is the cumulative distribution function. It’s simple to use it to compute the complement, the probability that a dice roll is above some value, :
Here’s a quick example familiar to anyone who has played a fantasy tabletop RPG:
Alice’s character Ria is facing down a vicious gnoll. Ria strikes out with her longsword. In order to strike true, Alice needs to roll above an 11 on a d20. What is the probability that Ria successfully attacks the gnoll?
Using the above result: . Despite Ria’s skill with a blade, her chances are slightly worse than the flip of a coin.
To try to hammer home what we mean by the probabilities of a single dice roll, the below chart shows the probability of a particular outcome for a 6-sided dice roll — unsurprisingly, it’s flat. You can click and shift-click the bars to calculate the sum of outcomes and get the same results that the CDF would give you:
One roll more
All right, so one dice roll is pretty straightforward. There is not much more to say than what we have above. Most games that use dice often have variety in both the number and types of dice to add complexity and nuance. As an obvious step from the previous section, we will look at what happens when rolling two dice instead of one — such a setup forms the basis of casino games like craps.
The first point to note is that when we roll two dice, the outcome of one has no effect on the outcome of the other — in the parlance of probability, we say that the two dice are independent. Independence tells us that the probability of a joint outcome is the product of the two individual outcomes. If represent the two dice rolls, then:
This allows us to directly calculate particular joint outcomes using the PMF that we define for the single dice roll case. As a quick example:
What is the probability of rolling snake eyes (two 1s) on two 6-sided dice?
Directly from above, we calculate
While this gives us all the machinery we need to calculate joint outcomes, it is not what we are usually interested in when we roll two dice. More often, we want to know the total value shown. We can use to represent the sum of two dice rolls as a random variable. There are a number of ways to calculate the probabilities — often you see counting up the number of ways to get a particular sum and dividing that by the total possible outcomes. Here we are going to do a little random variable algebra and arrive at the same result:
The last step uses the law of total probability to allow us to write this sum as a product of the individual probabilities of and . From before, we know the probabilities are both , but only when their argument is within the range . In the above summation, we need to take care to determine when a term is non-zero. We will rewrite our PMF with helpful notation as:
The boldface, , is the indicator function that is 1 when the argument is within and 0 otherwise. This is just a way to rewrite our piecewise function from before in a more compact way. If we apply this to our expression for above, we get:
We can pull the factor of out of the sum and the second indicator function is always 1 since the values of that we are summing up are exactly the values for which the PMF is nonzero, so this gives:
Since the indicator function either takes on the value of 1 or 0, we just need to count up the number of times that it takes on a value of 1. We do this by first writing the inequality that would satisfy the indicator function:
Since is bounded by and in the summation, we can add those additional bounds to get:
Now we just count up the number of integers in these bounds, multiply by the factor of that we pulled out and we have out PDF for :
A simple example shows how we can use it:
Sam is shooting craps in Vegas and rolls two 6-sided dice. He needs the dice to add up to 7 to win his bet. What are the chances of Sam winning?
Directly from the above PMF: , we see Sam will win this bet 1-in-6 times.
A better way to get an idea of how the sum of two dice rolls behaves is to look at the shape of the distribution, shown below. The uniform distribution that characterizes a single roll has been replaced by a symmetric, triangular distribution.
One of the key properties of adding together multiple dice rolls is that the distribution gets narrower and the majority of the results fall near the average outcome. Sums of dice rolls rather quickly approach a normal distribution as you increase the number of dice.
There will be time to explore the world beyond rolling just two dice, but that is another post for another day.