Did xkcd Get Its Math Right?¶

Fiddler¶

From Seth Cohen comes a comical conundrum:

Seth recently saw the following xkcd webcomic by Randall Munroe:

The question is, very simply: Is this comic mathematically correct?

In other words, let p represent the probability that if you randomly select two arrows from a group of 10 (five of which are cursed), neither arrow is cursed. And let q represent the probability that if you roll three d6 dice (cubes with faces numbered 1 through 6) and one d4 die (a tetrahedron with faces numbered 1 through 4), the sum of the rolls is at least 16.

Does p equal q? If so, determine their common value. If not, determine the value of each.

Solution¶

Arrows.¶

$$ \begin{align*} p &= \frac{\text{Choose two arrows from 5 non-cursed}}{\text{Choose two arrows from 10}} \\ &= \frac{5 \choose 2}{10 \choose 2} \\ &= \frac{10}{45} = \boxed{\frac{2}{9}}\\ \end{align*} $$

Dice.¶

It is well known that the probability of two d6 is:

Probability of Two d6
Sum $2$ $3$ $4$ $5$ $6$ $7$ $8$ $9$ $10$ $11$ $12$
Probability $\frac{1}{36}$ $\frac{2}{36}$ $\frac{3}{36}$ $\frac{4}{36}$ $\frac{5}{36}$ $\frac{6}{36}$ $\frac{5}{36}$ $\frac{4}{36}$ $\frac{3}{36}$ $\frac{2}{36}$ $\frac{1}{36}$


To get that of three d6, add consecutive probabilities (up to six consecutive numbers) from above, and divide by 6. :

Probability of Three d6
Sum $3$ $4$ $5$ $6$ $7$ $8$ $9$ $10$ $11$ $12$ $13$ $14$ $15$ $16$ $17$ $18$
Probability $\frac{1}{216}$ $\frac{3}{216}$ $\frac{6}{216}$ $\frac{10}{216}$ $\frac{15}{216}$ $\frac{21}{216}$ $\frac{25}{216}$ $\frac{27}{216}$ $\frac{27}{216}$ $\frac{25}{216}$ $\frac{21}{216}$ $\frac{10}{216}$ $\frac{15}{216}$ $\frac{6}{216}$ $\frac{3}{216}$ $\frac{1}{216}$


To get that of three d6 and a d4, add consecutive probabilities (up to four consecutive numbers) from above, and divide by 4. :

Probability of Three d6 & One d4
Sum $4$ $5$ $6$ $7$ $8$ $9$ $10$ $11$ $12$ $13$ $14$ $15$ $16$ $17$ $18$ $19$ $20$ $21$ $22$
Probability $\frac{1}{864}$ $\frac{4}{864}$ $\frac{10}{864}$ $\frac{20}{864}$ $\frac{34}{864}$ $\frac{52}{864}$ $\frac{71}{864}$ $\frac{83}{864}$ $\frac{100}{864}$ $\frac{104}{864}$ $\frac{100}{864}$ $\frac{83}{864}$ $\frac{71}{864}$ $\frac{52}{864}$ $\frac{34}{864}$ $\frac{20}{864}$ $\frac{10}{864}$ $\frac{4}{864}$ $\frac{1}{864}$


Answer¶

$$P(16 \le \text{sum}) = \frac{71+52+34+20+10+4+1}{864} = \frac{192}{864} = \boxed{\frac{2}{9}}$$

...of course xkcd math checks out.

Extra Credit¶

From Seth Cohen also comes some Extra Credit:

A typical set of dice from Dungeons & Dragons (D&D) includes a d4, a d6, a d8, a d10, a d12, and d20. Here, “dN” indicates a die with N faces numbered 1 through N that are all equally likely to come up.

Again, let p represent the probability that if you randomly select two arrows from a group of 10 (five of which are cursed), neither arrow is cursed.

You want to simulate this event by rolling up to four D&D dice and having the sum be at least some specific value. These dice can all be different from each other, they can all be the same kind of die (say, d4), or anywhere in between, with a few that are the same and others that are different.

How many ways can you simulate picking the arrows, an event with probability p? And what are these ways? (For each way, you should specify the dice as well as the value their sum should be greater than or equal to.)

Solution¶

I created code that did the following :

  1. Start with :
    1. A dictionary of d4, d6, d8, d10, d12, and d20 pointing to a list of their respective faces.
    2. All possible combinations of dice. 4 stars between 5 bars $\implies {9 \choose 5} = 126$ dice combinations.
  2. For each dice combination :
    1. Initiate a list of total sums, with a single element of 0.
    2. For die in dice combination :
      1. Initiate an empty list of new total sums.
      2. For each face on die :
        • For each total in total sums :
          • Add face to total, and append it to new total sums.
      3. Replace total sums with new total sums, as those will be the sums the next die's faces will be successively added to.
    3. Calculate frequency distribution from total sums.
    4. Calculate reverse cumulative frequency distribution from frequency distribution.
    5. If reverse cumulative frequency distribution is $\frac{2}{9}$, print total and dice combination.

Answer¶

There are three answers:

  1. Rolling at least a 16 with d4, d6, d6, and d6. (Dice Combination 7)
  2. Rolling at least a 21 with d6, d6, d8, and d10. (Dice Combination 30)
  3. Rolling at least a 36 with d10, d12, d12, and d20. (Dice Combination 110)

I animated the (reverse) cumulative probability distributions of all 126 dice combinations.

Maybe I'll think of something else...

Rohan Lewis¶

2024.12.02¶

Code can be found here.