Monday, January 15, 2024

Dice Dungeon

Two people are sitting at a table together, each with their own bag of six “DnD dice”: a d4, a d6, a d8, a d10, a d12, and a d20. Both people randomly pick one die from their respective bags and then roll them at the same time. For example, suppose the two dice selected are a d4 and a d12. The players roll them, and let’s further suppose that both rolls come up as 3. What luck!

What’s the probability of something like this happening? That is, what is the probability that both players roll the same number, whether or not they happened to pick the same kind of die?

There are twenty possible outcomes $1, 2, \dots, 20$, however, since for instance, the probability that a d4 die rolls 17 is nil, we have a non-uniform distribution of outcomes. All outcomes less than or equal to $4$ are always possible no matter which die is selected, so the probability is $$p_i = \frac{1}{6} \left( \frac{1}{4} + \frac{1}{6} + \frac{1}{8} + \frac{1}{10} + \frac{1}{12} + \frac{1}{20} \right) = \frac{93}{720}, \,\, i = 1, 2, 3, 4.$$ The conditional probability of getting i \in \{5,6\} given that the d4 die was selected is zero, so we have $$p_i = \frac{1}{6} \left( 0 + \frac{1}{6} + \frac{1}{8} + \frac{1}{10} + \frac{1}{12} + \frac{1}{20} \right) = \frac{63}{720}, \,\, i = 5,6.$$ Doing similar manipulations for other outcomes gives $$p_i = \begin{cases} \frac{93}{720}, &\text{for $i = 1, 2, 3, 4$}\\ \frac{63}{720}, &\text{for $i = 5,6$;}\\ \frac{43}{720}, &\text{for $i = 7,8$;}\\ \frac{28}{720}, &\text{for $i = 9,10$;}\\ \frac{16}{720}, &\text{for $i = 11,12$;}\\ \frac{6}{720}, &\text{for $i = 13, 14, 15, 16, 17, 18, 19, 20$.}\end{cases}$$

Let the roll person 1 be $X,$ with probability distribution given by $\mathbb{P} \{ X = i \} = p_i.$ Similarly let the roll of person 2 be $Y,$ which has the i.i.d. distribution. Then the probability that both rolls are the same, i.e., $X=Y,$ is given by \begin{align*}\mathbb{P} \{ X = Y \} &= \sum_{i=1}^{20} \mathbb{P} \{ X = Y = i \} \\ &= \sum_{i=1}^{20} \mathbb{P} \{X=i\} \mathbb{P} \{Y = i\}\\ &= \sum_{i=1}^{20} p_i^2 \\ &= \frac{1}{720^2} \left( 4 \cdot 93^2 + 2 \cdot 63^2 + 2 \cdot 43^2 + 2 \cdot 28^2 + 2 \cdot 16^2 + 8 \cdot 6^2 \right) \\ &= \frac{48600}{518400} = \frac{3}{32} = 9.375\%.\end{align*}

If we went further and added a third person who has a bag of DnD dice. Again, all three randomly pick one die from their respective bags and roll them at the same time. For example, suppose the three dice selected are a d4, a d20, and a d12. The players roll them, and let’s further suppose that the d4 comes out as 4, the d20 comes out as 13, and the d12 comes out as 4. In this case, there are two distinct numbers (4 and 13) among the three rolls.

On average, how many distinct numbers would you expect to see among the three rolls?

Well the hard part of establishing the distribution is done, so let's assume $X$, $Y$ and now $Z$ are all i.i.d. with $\mathbb{P}\{X = i\} = \mathbb{P}\{Y=i\} = \mathbb{P}\{Z=i\} = p_i, i = 1, 2, \dots, 20.$ Let $N$ be the number of distinct rolls. I'm lazy so I'm going to leave $N=3$ alone and instead tackle $N=1$ and $N=2.$ The probability that $X=Y=Z$ and hence $N = i$ is by extension of the previous problem $$\mathbb{P} \{N=1\} = \sum_{i=1}^{20} p_i^3 = \frac{3930360}{373248000} = \frac{32753}{3110400} \approx 1.05302.....\%$$

For $N=2,$ we have a modicum of work. As we saw above if $X=Y$ then this would be represented by $p_i^2,$ but then in this case of $N = 2,$ we must have $Z \ne X=Y,$ which has probability of $(1-p_i).$ Furthermore, since the order of $X, Y, Z$ doesn't matter, there are 3 possible ways to get two rolls of $i$ and one roll of anything but $i.$ So we have $$\mathbb{P} \{ N=2\} = 3 \sum_{i=1}^{20} p_i^2 (1-p_i) = \frac{93184920}{373248000} = \frac{776541}{3110400} \approx 24.96595....\%$$

The only thing left to do is compute the expectation, \begin{align*}\mathbb{E} [N] &= 1 \cdot \mathbb{P} \{ N=1\} + 2 \cdot \mathbb{P} \{N=2\} + 3 \cdot \left( 1- \mathbb{P}\{N=1\} - \mathbb{P} \{N=2\} \right)\\ &= 3 - 2\mathbb{P} \{N=1\} -\mathbb{P}\{N=2\}.\end{align*} So the expected number of unique numbers among the three rolls is \begin{align*}\mathbb{E}[N] &= 3 - 2 \cdot \frac{32753}{3110400} - \frac{776541}{3110400} \\ &= \frac{9006847}{3110400} \approx 2.89571984\end{align*}

1 comment:

  1. Arithmetic strikes again! While the first formula for E[N] is correct, the appropriate numerator and final answer are 8489153 and 2.72928015689..., respectively.

    ReplyDelete