Solving a Three-Dice Problem Using Two Approaches

Introduction

In his book, Do Dice Play God, Ian Stewart wrote

For three dice, Cardano solved a long-standing conundrum. Gamblers had long known from experience that when throwing three dice, a total of 10 is more likely than 9. This puzzled them …

In this note, I will focus my attention to the so-called 3-dice problem: We roll three dice simultaneously; what’s the probability that we get a total $t$, where $t = 3,\ 4,\ \ldots,\ 18$?

The probability that we get a total $t$ is

$$ \frac{C(t)}{6^3}=\frac{C(t)}{216}, $$

where $C(t)$ is the count of throws with total being equal to $t$. For getting $C(t)$, I will next show a generating function approach and a brute force approach (i.e. an R function).

Generating function approach

We define

$$ \begin{array}{ccl} g(x) &=& (x + x^2 +\cdots+x^6)^3\\ &=& x^3(1+x+\cdots+x^5)^3. \end{array} $$

The desired number $C(t)$ is nothing but the coefficient of $x^t$ in $g(x)$, or $C(t)$ is equal to the coefficient of $x^{t-3}$ in

$$ \begin{array}{ccl} g_1(x) &=& (1+x+\cdots+x^5)^3\\ &=& \left(\frac{1-x^6}{1-x}\right)^3\\ &=& (1-x^6)^3 (1-x)^{-3}. \end{array} $$

We know that

$$ (1-x^6)^3 = 1 - 3x^6 + 3x^{12} - x^{18}, $$

and

$$ \begin{array}{ccl} (1-x)^{-3} &=& \sum_{i=0}^{+\infty} (-1)^i {-3 \choose i} x^i\\ &=& \sum_{i=0}^{+\infty} {3+i-1 \choose i} x^i\\ &=& \sum_{i=0}^{+\infty} {i+2 \choose 2} x^i. \end{array} $$

Letting

$$ u = t - 3, $$

thus,
  • for $0\le u \le 5$,

$$ C(t) = {u+2 \choose 2}; $$

  • for $6 \le u \le 11$,

$$ \begin{array}{ccl} C(t) &=& {u+2 \choose 2} - 3{u-6+2 \choose 2}\\ &=& {u+2 \choose 2} - 3{u-4 \choose 2}; \end{array} $$

  • for $12 \le u \le 15$

$$ \begin{array}{ccl} C(t) &=& {u+2 \choose 2} - 3{u-4 \choose 2} + 3{u-12+2 \choose 2}\\ &=& {u+2 \choose 2} - 3{u-4 \choose 2} + 3{u-10 \choose 2}. \end{array} $$

Replacing $u$ with $t-3$ in the above, we have
  • for $3\le t \le 8$,

$$ C(t) = {t-1 \choose 2}; $$

  • for $9\le t \le 14$,

$$ C(t) = {t-1 \choose 2} - 3{t-7 \choose 2}; $$

  • for $15\le t \le 18$,

$$ C(t) = {t-1 \choose 2} - 3{t-7 \choose 2} + 3{t-13 \choose 2}. $$

Remark: In the above we have used the following well known result:

$$ \begin{array}{ccl} (1-x)^{-n} &=& \sum_{i=0}^{+\infty} (-1)^i {-n \choose i} x^i\\ &=& \sum_{i=0}^{+\infty} {n+i-1 \choose i} x^i\\ &=& \sum_{i=0}^{+\infty} {n+i-1 \choose n-1} x^i. \end{array} $$

Brute force approach

n_dice_problem <- function(n = 3)
{x <- rep(list(1:6), n) 
 y <- as.matrix(expand.grid(x))
 table(rowSums(y))
}

(n_dice_problem(n = 3))
## 
##  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 
##  1  3  6 10 15 21 25 27 27 25 21 15 10  6  3  1
(n_dice_problem(n = 4))
## 
##   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19  20  21  22  23 
##   1   4  10  20  35  56  80 104 125 140 146 140 125 104  80  56  35  20  10   4 
##  24 
##   1

Generalizing 3-dice problem to n-dice problem

An obvious generalization of the 3-dice problem is an $n$-dice problem, where $n$ can be any a positive integer. Let $C^{(n)}(t)$ denote the count of throws with the total of $n$ dice being equal to $t$. Since we already knew how to get $C^{(3)}(t)$ (generating-function approach), it is easy to have

$$ C^{(n)}(t) = \sum_{i=0}^{\lfloor (t-n)/6 \rfloor}(-1)^i {n \choose i} {t-6i-1 \choose n-1}, $$

where $t = n,\ n+1,\ \ldots,\ 6n$.

In the brute-approach section, we already have R function n_dice_problem(), but because of computer memory limit the value of $n$ cannot be larger than 10. We have the following R code, in which the value of $n$ can be large, say at least as large as 100.

library(gmp)
c_n_t  <- function(t, n) {
  a <- floor((t - n) / 6)
  i <- as.bigz(0:a)
  temp <- (-1)^i * chooseZ(n, i) * chooseZ(t - 6*i - 1, n - 1)
  sum(temp)
}
c_n_t(300, 100)
## Big Integer ('bigz') :
## [1] 207241756759032546720209656767808329086730171654102671945216674007548108775

Acknowledgment: I thank Professor Martin Maechler of ETH Zurich for pointing me to gmp package.

Reference

[1] Stewart, I. Do Dice Play God? pp. 29-30.

Lingyun Zhang (张凌云)
Lingyun Zhang (张凌云)
Design Analyst

I have research interests in Statistics, applied probability and computation.