4

For example, if I want to roll n=6,

with 1 die it can be thrown in $$\binom {5} {0} = 1$$ way, with 2 dice $$\binom {5} {1} = 5$$ 3 dice $$\binom {5} {2} = 10$$ 4 dice $$\binom {5} {3} = 10$$ 5 dice $$\binom {5} {4} = 5$$ 6 dice $$\binom {5} {5} = 1$$ The sum of these is 32 - the correct answer, I believe.

I thought that the answer for any number n (where the number of dice is d) is $$\sum_{d=1}^{d=n} \binom {n-1} {d-1}$$ It seems that this isn't working, though. For example the correct answer for n=8 is 125, but this equation gives me 128. Where am I going wrong? Thanks in advance.

Kurns
  • 45
  • Hi Kurns, what are you actually counting with ${{n-1} \choose {d-1}}$? – 57Jimmy Jan 05 '18 at 08:40
  • 1
    The number of ways the number n can be rolled with d dice. – Kurns Jan 05 '18 at 08:42
  • Sure, but why can one compute it that way? What are you really counting? – 57Jimmy Jan 05 '18 at 10:04
  • I read that online... and it seems to work, to a point at least – Kurns Jan 05 '18 at 10:14
  • 1
    Though $\binom{7}{0}=1$, you cannot roll an 8 with one die, and though $\binom{7}{1} = 7$ there are only 5 ways to roll an 8 with two dice. – Fabio Somenzi Jan 05 '18 at 10:15
  • That does make sense. Should I start over or could this method be adjusted somehow? – Kurns Jan 05 '18 at 10:19
  • The formula you wrote works if $n \leq 6$. For $n > 6$, you need to exclude those cases in which one of the summands exceeds $6$. – N. F. Taussig Jan 05 '18 at 10:55
  • Thanks for pointing that out https://math.stackexchange.com/users/123852/fabio-somenzi and N. F. Taussig! I am only left with one question: is there an easy way to exclude those cases? I am programming this so it is pretty difficult to mess around with those exponents. – Kurns Jan 05 '18 at 11:00
  • It might be easier to use the recurrence for ways $W_{n,r}$ to score $n$ with $r$ dice: $$W_{n,r}=\sum_{j=1}^{6}W_{n-j,r-1}$$ since any score of $n$ with $r$ dice can be formed from a score of $n-1$ with $r-1$ dice and a "1" on the last die or a score of $n-2$ with $r-1$ dice and a "2" on the last die and so on up to a score of $n-6$ on $r-1$ dice and a "6" on the last die. The recurrence can also be simplified to $$W_{n,r}=W_{n-1,r}+W_{n-1,r-1}-W_{n-7,r-1}$$ with starting values $W_{n,1}=1$ for $n=1\ldots 6$ and $W_{n,1}=0$ otherwise and $W_{0,r}=0$. This assumes distinct dice. – N. Shales Jan 05 '18 at 17:08
  • Nice thinking! I actually coded this - its only challenge is that it is slow with bigger numbers because of the recursion. – Kurns Jan 05 '18 at 22:04
  • Your welcome @Kurns. There is a closed form summation here, the formulation of this actually parallels the recurrence if generating functions are used. The answer in the link cites inclusion-exclusion however. I believe there are quite a few questions on MSE regarding 'balls in bins with limited capacity' so a more thorough search will likely yield you a fuller answer. On another note: the recurrence is really easy to put into a spreadsheet to form a Pascal-like-triangle :) – N. Shales Jan 06 '18 at 01:03
  • Sorry, that should be "you're welcome". Also you should bear in mind that $W_{n,r}$ values for any given $r$ are symmetrically distributed over $n$ values, this might save some computing power. – N. Shales Jan 06 '18 at 01:11

1 Answers1

2

The answer is surprisingly complicated. The number of ways to roll $n$ with $m$ die is the coefficient of $x^n$ in the generating function

$$(x + x^2 + \dots + x^6)^m = x^m \left( \frac{1 - x^6}{1 - x} \right)^m.$$

This can be simplified somewhat but not substantially by applying the binomial theorem to $(1 - x^6)^m$ and $\frac{1}{(1 - x)^m}$ (here you will need the binomial theorem with negative exponents).

Qiaochu Yuan
  • 419,620