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, , 18?

The probability that we get a total t is

C(t)63=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

g(x)=(x+x2++x6)3=x3(1+x++x5)3.

The desired number C(t) is nothing but the coefficient of xt in g(x), or C(t) is equal to the coefficient of xt3 in

g1(x)=(1+x++x5)3=(1x61x)3=(1x6)3(1x)3.

We know that

(1x6)3=13x6+3x12x18,

and

(1x)3=i=0+(1)i(3i)xi=i=0+(3+i1i)xi=i=0+(i+22)xi.

Letting

u=t3,

thus,
  • for 0u5,

C(t)=(u+22);

  • for 6u11,

C(t)=(u+22)3(u6+22)=(u+22)3(u42);

  • for 12u15

C(t)=(u+22)3(u42)+3(u12+22)=(u+22)3(u42)+3(u102).

Replacing u with t3 in the above, we have
  • for 3t8,

C(t)=(t12);

  • for 9t14,

C(t)=(t12)3(t72);

  • for 15t18,

C(t)=(t12)3(t72)+3(t132).

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

(1x)n=i=0+(1)i(ni)xi=i=0+(n+i1i)xi=i=0+(n+i1n1)xi.

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)=i=0(tn)/6(1)i(ni)(t6i1n1),

where t=n, n+1, , 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.