Why the Horner scheme with dice?

Why not just add up the dots?

This is often the first idea on how to generate random numbers. Unfortunately, we quickly see a bias:

Second throw
First throw 1 2 3 4 5 6
1 2 3 4 5 6 7
2 3 4 5 6 7 8
3 4 5 6 7 8 9
4 5 6 7 8 9 10
5 6 7 8 9 10 11
6 7 8 9 10 11 12

More accurately, we obtain the following distribution:

Sum Relative Frequency
21
32
43
54
65
76
85
94
103
112
121

This means that the value 7 is six times more likely to appear than the value 2. That is not a uniform distribution.

Why not just juxtapose/concatenate the digits?

That does seem a bit fairer. However, the die probably only has sides with at least 1 and at most 6 dots, which means the digits 0, 7, 8 and 9 will never occur.

So what does the Horner scheme do?

It takes the juxtaposition/concatenation idea and modifies it to make sure that there are no “impossible digits”.

A juxtaposition/concatenation of a digit to the end a number is the same as:

Why the number 10? The reason is that we have ten different options that a digit can be (0, 1, 2, 3, 4, 5, 6, 7, 8, and 9), so to ensure that the new digit is independent of all the digits in the previous number, we must “make space” for the new digit by multiplying the previous number by the number of options that the new digit can have.

And that’s the whole trick, really. Since a six-sided die only has six options, we don’t multiply by ten before adding the next roll, but just by six. We also have to map the die dots (1 dot to 6 dots) to the digit range of 0 to 5, since 6 is technically already the next “rank”. (If this feels puzzling, consider a ten-sided die with 1 to 10 dots – 10 is obviously a special number of dots unlike the others because it has two digits.)

So all that happens is:

  1. Map the dots on the die to the numbers 0 to n where n is one less than the total number of sides on the die.
  2. Start with the number 0.
  3. As often as necessary:
    1. Multiply the number by 10.
    2. Roll the die.
    3. Add the value corresponding to the dots on the top side of the die (see step 1).