2

In my probability book I learned how to solve this kind of problem: how many vectors of the form $(i_1,i_2,...,i_r)$ exist that the sum of its components is $n$ and $i_k>0$ for all $k$? The answer uses the stars and bars argument and is $n-1\choose r-1$.

OK, now I have this really simple problem: imagine you'll roll $2$ six-faced dice, how many ways there are in which the sum of them is $n$?

First I thought to use the before mentioned method, considering a result as a vector of the form $(i_1,i_2)$ but I realized that I have a new restriction, $i_1,i_2 \leq 6$! I thought about it and I don't know how to compute it without considering case by case ($n=2,n=3,...,n=12$), I've done it with the six-faced die, since there's only $11$ cases and found a nice 'triangular pattern', but what if the dice had each $20$ faces? Is there a more smart way to calculate it?

N. F. Taussig
  • 79,074

4 Answers4

7

Hint:

This might help. $$\begin{array}{|l|l|l|l|l|l|l|} \hline & \color{red}1 & \color{red}2 & \color{red}3 & \color{red}4 & \color{red}5 & \color{red}6 \\ \hline \color{red}1 & 2 & 3 & 4 & 5 & 6 & 7 \\ \hline \color{red}2 & 3 & 4 & 5 & 6 & 7 & 8 \\ \hline \color{red}3 & 4 & 5 & 6 & 7 & 8 & 9 \\ \hline \color{red}4 & 5 & 6 & 7 & 8 & 9 & 10 \\ \hline \color{red}5 & 6 & 7 & 8 & 9 & 10 & 11 \\ \hline \color{red}6 & 7 & 8 & 9 & 10 & 11 & 12 \\ \hline \end{array}$$


Let $n$ be your sum, then notice that

  • if $n\leq 6$, then there are $n-1$ ways to make a sum equal to $n$.
  • if $n\geq 7$, then there are $13-n$ ways to make a sum equal to $n$.

We can jusify this as follows. Say you want to pick two numbers $a,b$ so that $$a+b=n$$ We can only focus on $a$, since for a fixed $a$ we know that $b=n-a$. The smallest value for $a$ is $1$, and the largest value for $a$ is therefore $n-1\geq n-a$. Thus there are $n-1$ ways to choose $a$ (and we have no choice for $b$).

We get the other case by symmetry: $12-(n-1)$.

cansomeonehelpmeout
  • 14,020
  • 3
  • 29
  • 55
3

Six-sided dice problem:

Suppose we have a red die and a white die. If we denote the number shown on the red die by $x_r$ and the number shown on the white die by $x_w$, then the sum of the numbers on the two dice satisfies $$x_r + x_w = n \tag{1}$$ where $x_r$ and $x_w$ are positive integers. For six-sided dice, we have the additional restriction that $x_r, x_w \leq 6$. Without that restriction, equation 1 has $$\binom{n - 1}{2 - 1} = \binom{n - 1}{1} = n - 1$$ solutions in the positive integers. From these, we must subtract those solutions in which one of the variables exceeds $6$.

If $n \leq 7$, this is impossible, so there are simply $n - 1$ solutions.

Suppose $n > 7$. Moreover, suppose $x_r \geq 7$. Then $x_r' = x_r - 6$ is a positive integer. Substituting $x_r' + 6$ for $x_r$ in equation 1 yields \begin{align*} x_r' + 6 + x_w & = n\\ x_r' + x_w & = n - 6 \tag{2} \end{align*} Equation 2 is an equation in the positive integers with $$\binom{n - 6 - 1}{1} = \binom{n - 7}{1} = n - 7$$ solutions. By symmetry, equation 1 also has $n - 7$ solutions in the positive integers with $x_w > 6$.

Hence, the number of ways two six-sided dice can have sum $n > 7$ is $$n - 1 - 2(n - 7) = n - 1 - 2n + 14 = 13 - n$$ The approach is analogous for $20$-sided dice.

N. F. Taussig
  • 79,074
0

If the first die shows $d$, the other must show $n-d$. You must fulfill the constraints

$$1\le d\le6,\\1\le n-d\le 6$$ or

$$\max(1,n-6)\le d\le\min(6,n-1).$$

The requested number is

$$\min(6,n-1)-\max(1,n-6)+1.$$


In a simpler way,

$$2=1+1, \\3=2+1|1+2, \\4=3+1|2+2|1+3, \\5=4+1|3+2|2+3|1+4, \\\cdots$$

0

(Generating functions method) If $A$ is the first dice roll result and $B$ is the second, you want the number of pairs $(A,B)$ such that $A+B=n$, restricted by $A,B\in \{1,2,3,\dots,6\}$. This is (if dice ordering is important)

$$ S_n=\sum_{k=0}^6 \mathbb 1_{k} \mathbb 1_{n-k}=\sum_{k=0}^n \mathbb 1_{k} \mathbb 1_{n-k}, \quad \mathbb 1_k := \begin{cases}1 & k\in \{1,2,3,\dots,6\}, \\ 0 & \text{otherwise.}\end{cases}$$ i.e. it is the convolution product of the sequence $\mathbb 1_k$ with itself. Recall that convolution products correspond to the coefficients of the product of polynomials(or even formal power series),

$$ A(x) = \sum a_i x^i , B(x) = \sum b_i x^i \implies A(x)B(x) = \sum c_i x^i, \quad c_i =\sum_{i=0}^na_i b_{n-i}.$$

So lets consider $P(x) = \sum_{k=0}^\infty\mathbb 1_k x^k = \sum_{k=1}^6 x^k = x + x^2 + x^3 + ... + x^6 $. Then the product $$ P(x)^2 = \sum_{k=0}^{12} S_k x^k. $$ On the other hand, $$P(x)^2 = \left( \sum_{k=1}^6 x^k\right)^2 = x^2 + 2 x^3+ 3 x^4+ 4 x^5 + 5 x^6 + 6 x^7 + 5 x^8+ 4 x^9+ 3 x^{10}+ 2 x^{11}+ x^{12}. $$

So computing this polynomial $P(x)^2$ computes all elements of $S_n$ at once. To get the answer for 20, just change 6 to 20 and compute the polynomial $P(x)^2 = (\sum_{k=1}^{20} x^k)^2$. This is just (I see no one else here has computed this explicitly) $$P(x)^2 = x ^ { 40 } + 2 x ^ { 39 } + 3 x ^ { 38 } + 4 x ^ { 37 } + 5 x ^ { 36 } + 6 x ^ { 35 } + 7 x ^ { 34 } + 8 x ^ { 34 } + 8 x ^ { 33 } + 10 x ^ { 32 } + 10 x ^ { 31 } + 11 x ^ { 30 } + 12 x ^ { 29 } + 13 x ^ { 28 } + 14 x ^ { 27 } + 15 x ^ { 26 } + 16 x ^ { 25 } + 17 x ^ { 24 } + 18 x ^ { 23 } + 19 x ^ { 22 } + 20 x ^ { 21 } + 19 x ^ { 20 } + 18 x ^ { 19 } + 17 x ^ { 17 } + 16 x ^ { 17 } + 15 x ^ { 16 } + 14 x ^ { 15 } + 13 x ^ { 14 } + 12 x ^ { 13 } + 11 x ^ { 12 } + 10 x ^ { 11 } + 9 x ^ { 10 } + 7 x ^ { 9 } + 6 x ^ { 7 } + 5 x ^ { 6 } + 4 x ^ { 5 } + 3 x ^ { 4 } + 2 x ^ { 3 } + x ^ { 2 } $$

So for instance, there are 19 ways to get a sum of 22 with 2 20-sided dice. Its easy to generalise this to any number of dice as well: if you want the number of ways to get $k$ from rolling $M$ distinct $N$-sided die, look at the $k$th coefficient in $(\sum_{1}^N x^k)^M$. This method is very robust and can solve many other counting problems, see e.g. this wikipedia page of examples, and also the incredible Generatingfunctionology book linked at the bottom of that page.

Calvin Khor
  • 36,192
  • 6
  • 47
  • 102