Probability of sum of N dice being above certain value X

diceprobability

In Dnd, sometimes you have to roll n, m-sided dice (say 5, d20s) and have the sum be greater than or equal to a certain value, x (say 90).

This is easy for me to calculate by brute force, for most typical examples. I simply take the total number of possibilities that meet the criteria, and divide by the total number of possibilities, by running through each combination of dice rolls. My result for the above example is 3003 dice combinations that sum to > 90, out of 3200000 combinations in total p = 0.009384375 chance of getting 90 or over.

Is there a way (e.g. an equation) to reach this value directly?

Best Answer

Concerning a "closed" ( = finite summation) formula, start from $$ \eqalign{ & N_b (s - n,m - 1,n) = {\rm No}{\rm .}\,{\rm of}\,{\rm solutions}\,{\rm to}\;\left\{ \matrix{ {\rm 1} \le {\rm integer}\;x_{\,j} \le m \hfill \cr x_{\,1} + x_{\,2} + \; \cdots \; + x_{\,n} = s \hfill \cr} \right. = \cr & = {\rm No}{\rm .}\,{\rm of}\,{\rm solutions}\,{\rm to}\;\left\{ \matrix{ 0 \le {\rm integer}\;y_{\,j} \le m - 1 \hfill \cr y_{\,1} + y_{\,2} + \; \cdots \; + y_{\,n} = s - n \hfill \cr} \right. \cr} $$ where $N_b$ is given by $$ N_b (s,r,m)\quad \left| {\;0 \leqslant \text{integers }s,m,r} \right.\quad = \sum\limits_{\left( {0\, \leqslant } \right)\,\,k\,\,\left( { \leqslant \,\frac{s}{r+1}\, \leqslant \,m} \right)} {\left( { - 1} \right)^k \binom{m}{k} \binom { s + m - 1 - k\left( {r + 1} \right) } { s - k\left( {r + 1} \right)}\ } $$ as explained in this related post.

Then the number of ways to obtain a sum $x \le s$ is given by $$ \eqalign{ & M(x,m,n) = \sum\limits_{x\, \le \,s\,\left( { \le \,m\,n} \right)\,} {N_b (s - n,m - 1,n)} = \cr & = m^{\,n} - \sum\limits_{0\, \le \,s\, \le \,x - 1\,} {N_b (s - n,m - 1,n)} = \cr & = m^{\,n} - \sum\limits_{0\, \le \,s\, \le \,x - n - 1\,} {N_b (s,m - 1,n)} = \cr & = m^{\,n} - \sum\limits_{0\, \le \,s\, \le \,x - n - 1\,} {\sum\limits_{\left( {0\, \le } \right)\,\,k\,\,\left( { \le \,{s \over m}\, \le \,n} \right)} {\left( { - 1} \right)^k \left( \matrix{ n \hfill \cr k \hfill \cr} \right)\left( \matrix{ s + n - 1 - k\,m \cr s - k\,m \cr} \right)} } = \cr & = m^{\,n} - \sum\limits_{\left( {0\, \le } \right)\,\,k\,\,\left( { \le \,{s \over m}\, \le \,n} \right)} {\left( { - 1} \right)^k \left( \matrix{ n \hfill \cr k \hfill \cr} \right)\left( \matrix{ x - 1 - k\,m \cr x - n - 1 - k\,m \cr} \right)} \cr} $$

and in fact $M(90,20,5)=3003$.

Note that, as explained in the cited related post, the problem has the geometric equivalent of finding:
the number of integral points on the diagonal plane $y_1, \cdots, y_n=s-n$, intercepted by a $n$-D cube with side $[0,m-1]$.
The formula for $N_b$ corresponds to calculating the points on the whole plane ($k=0$) and subtracting those pertaining to the surrounding cubes.
The geometric analogy clearly shows that $N_b(nm-s,m,n)=N_b(s,m,n)$.