Chapter 2 of 6 · 10 min

Two dice: why the total is a triangle

Each face is equally likely, but the totals are not, because a total in the middle can be made in many ways and a total at the edge in only one. Count the ordered pairs.

By the end of this chapter you can
  • Count the ordered pairs that make a given total on two dice
  • Read 'at least' questions off the triangle, or off its complement
  • Find the expected value of the higher of two dice
  • Solve for the number of rolls from the chance of seeing a face at least once
1

The intuition

Roll two ordinary dice. A total of 7 can be made six ways: 1 and 6, 2 and 5, 3 and 4, and the same three the other way round. A total of 2 can be made one way. Out of 36 equally likely ordered pairs, 7 has probability 6 ÷ 36 and 2 has 1 ÷ 36. Plot the count of ways against the total and you get a triangle peaking at 7.

Every 'probability of a sum' question is this counting: dice, card totals, the number of defaults in a portfolio. The two habits interviewers test are listing ordered pairs, so that 1-and-6 and 6-and-1 are counted separately, and reaching for the complement when a question says 'at least one'. The chance of at least one six in four rolls is 1 minus the chance of no six at all.

The key idea

Two fair s-sided dice make s² ordered pairs. Ways to total t = s − |t − (s + 1)|, peaking at t = s + 1 with s ways. P(at least one k in n rolls of one die) = 1 − (1 − 1/s)ⁿ, so n = ln(1 − P) ÷ ln(1 − 1/s). P(higher of two dice = k) = (2k − 1) ÷ s².

2

Why it works

  • The conventions here: two fair dice, each with faces 1 to s, rolled independently. Outcomes are the s² ordered pairs. The comparative question swaps one die for one with a different number of faces, and counts over s × s₂ pairs.
  • Why a triangle. For a total t, the first die can show any a such that t − a is also a face. Near the middle every a works, so there are s ways; at the edges only one does. The count is s minus the distance of t from the peak, s + 1.
  • 'At least' is a sum of ways, or a complement. Above the peak the ways fall by one each step, so totals of s + 2 or more number (s − 1)s ÷ 2. Below the peak it is easier to count the small triangle of totals you do not want and subtract.
  • The higher of two dice. P(both ≤ k) = k² ÷ s², so P(max = k) = (k² − (k − 1)²) ÷ s² = (2k − 1) ÷ s². The expected maximum is above the average face, and the gap grows with the spread of the faces.
  • 'At least one k in n rolls' is a complement. Each roll misses k with probability 1 − 1/s; n independent rolls all miss with probability (1 − 1/s)ⁿ. Take logs to run it backwards for n.
  • Expected count is not probability. Six rolls of a six-sided die give one six on average, but the chance of at least one is only about 67%: some runs contain two or three sixes, which is exactly what leaves other runs with none.
Two six-sided dice
Ordered pairs: 6 × 636
P(total = 7): 6 ÷ 3616.67%
P(total = 10): (6 − |10 − 7|) ÷ 36 = 3 ÷ 368.33%
P(total ≥ 10): (3 + 2 + 1) ÷ 3616.67%
E[higher of two]: Σ k(2k − 1) ÷ 36 = 161 ÷ 364.472
P(at least one 6 in 4 rolls): 1 − (5/6)⁴51.77%

Swap one die for a four-sided one: pairs 6 × 4 = 24, and a total of 7 needs the first die between 3 and 6, four ways, so 4 ÷ 24 = 16.67%. The same probability as before, by coincidence of this total.

3

The formulas

Ways to total t = s − |t − (s + 1)|, out of s² pairs

The triangle: full at the peak, one at each edge.

P(total = t) = ways ÷ s²

Count over ordered pairs.

P(at least one k in n rolls) = 1 − (1 − 1/s)ⁿ; n = ln(1 − P) ÷ ln(1 − 1/s)

The complement, and its inverse in logs.

E[higher of two] = Σ k (2k − 1) ÷ s²

From P(max = k) = (2k − 1) ÷ s².

4

Worked example

Count the ordered pairs that make the total, then divide by all the pairs. The follow-up compares the total with the peak.

Drawing the numbers…
5

See it move

Same dice. Move the target total away from the peak, change the number of faces, and change how many times a single die is rolled.

Drawing the numbers…
Try this
  • Move the target away from the peak, either way. P(total = target) falls one step of 1 ÷ s² at a time; P(total ≥ target) falls as the target rises.
  • Add faces to the dice. The expected total and the expected higher die rise; watch P(total = target), which depends on the target and the pairs together.
  • Roll the single die more times. P(at least one top face) rises, and each extra roll adds less than the last.
6

Run it backwards

The chance of seeing at least one top face is known. How many rolls were made?

Drawing the numbers…

P(at least one) = 1 − (1 − 1/s)ⁿ, so the complement is (1 − 1/s)ⁿ. Take logs: n = ln(1 − P) ÷ ln(1 − 1/s).

The follow-up is the expected-count trap: s rolls give one top face on average, but well under a 100% chance of seeing at least one.

7

Traps

Counting 1-and-6 and 6-and-1 as one outcome.
Outcomes are ordered pairs. Unordered counting makes 7 and 12 look closer in probability than they are.
Saying every total is equally likely because each die is fair.
Faces are equally likely; totals are not. The middle totals have more ways.
Adding probabilities for 'at least one'.
Use the complement: 1 − P(none). Adding P(one) + P(two) + … works but takes n calculations.
Confusing the expected count with the probability.
Six rolls give one six on average but only about a 67% chance of at least one. Some runs have several.
Forgetting the range when one die changes.
With a smaller die some totals become impossible; with a bigger one the same total is spread over more pairs. Recount the valid first-die values.
8

Say it in the interview

The interviewer asks

Two dice. What is the chance of a total of 9, and of at least 9?

Say yours out loud first, then compare.
9

Check yourself

5 fresh questions, with new numbers. Answer each one correctly to finish the chapter. Get one wrong and you will see the full working, then you can try it again with new numbers.

Answers within 1% are marked right. Type the number; $, %, x and M are fine. First tries count toward Learned: the topic is Learned once every chapter is done and 75% of first tries were right.

0 of 5
Drawing your questions…
Remember
  • Ordered pairs: s² outcomes, and ways to total t = s − |t − (s + 1)|.
  • 'At least' is a sum along the triangle, or one minus the small triangle you do not want.
  • P(at least one k in n rolls) = 1 − (1 − 1/s)ⁿ; solve for n with logs.
  • E[higher of two] = Σ k(2k − 1) ÷ s², above the average face.