# Proof of Algebraic Formula for the Sum of Two-Dice Toss as a Convolution

To figure out exactly the expected frequency of a given sum in a dice toss (given a certain number of dice and sides/dice), the following formula is posted here by @Glen_b (adapted to dice of six sides, and two dice tossed) the multiplication of the probability of each outcome $\frac{1}{6^2}$ times whichever is less of either the $total(n) - 1$, or the maximum possible attainable (12) minus the total under consideration $((max+1)-n)$:

$$p(x) = P(X=n) = \frac{1}{36} \min(n-1,13-n)$$

On the same post we are reminded that the problem is really a convolution.

I have two questions about this formula: 1. Can it be generalized to any number of sides and tosses? And 2. It obviously works, but how can you prove it, perhaps making the connection to the mechanics of a convolution?

If the question is still OK, I'd like to follow up with yet a third problem: How is this formula connected to the proof by @whuber in here based on probability generating functions?

• Hint: Use your calculator to compute the square of the integer $111111$. Then try to check the answer via ordinary multiplication that is taught in elementary schools everywhere in the world except the US where it is slowly disappearing from the middle school curriculum. May 23 '15 at 19:49
• For an explicit connection and extensive generalization, see my post at stats.stackexchange.com/a/116913/919. It includes all the R code needed to carry out these convolutions and much more.
– whuber
Oct 26 '18 at 15:19

That formula doesn't directly generalize for any number of dice, but yes, that formula for two dice generalizes directly for different numbers of faces as long as the two dice are the same "size".

More generally for $$m$$ dice, you get piecewise polynomial functions, with $$m$$ polynomials of degree $$m−1$$. e.g. for 3 dice you'll get three quadratic pieces.

Let's look at an example for $$m=3$$. Here's three (six-sided) dice:

$$\qquad\qquad x\:\:\,$$: 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
$$6^3 P(X=x)$$: 1 3 6 10 15 21 25 27 27 25 21 15 10 6 3 1

Here are the corresponding 3d regions, shown in two different views; the 'red' points on the red-blue boundary should also be blue, and the 'blue' points on the blue-green boundary should also be green.

On the right-side image, height "up" the screen roughly corresponds to $$x$$ in the previous plot of the pmf.

Looking at it as a convolution of one die with the sum of two, we can describe what goes on in the three parts (left, right, center):

I've been looking for a visual explanation to tie up the formula in my OP with the idea of the total sum of dice tosses being an example of a convolution of discrete variables.

There are some posts on-line that display some interesting graphs, but yet they do the actual calculations on the side. Likewise some code including either the combinatorics concept of composition, or tackling explicitly this idea through an outer product such in R, outer(1:6,1:6,"+"), also separate the actual computation of permutations adding up to the total, as opposed to performing one single convolution. This makes a lot of sense, but it doesn't quite help get a good visual.

So I worked through this, and hope that this answer may help others also without strong mathematical background grasp the idea of convolutions.

We have two 6-sided dice (d1 and d2) and the probability distribution of the addition of their values will be given by a convolution, such that:

$$p\,(d1 + d2 = n) = \displaystyle\sum_{k\,=\,0}^{k\,=\,n}\, p\,(d1\,=\,k)\cdot\,p(d2\,=\,n-k)$$ Since d1 and d2 are to independently distributed random variables, the multiplication is justified. On the other hand, the sigma notation is meant to include all the situations (compositions) where the total addition will be equal to $$n$$, given that $$d1 = k$$ and $$d2 = n -k$$, and hence their sum equals $$k +(n-k) = n$$.

For total sum values less or equal to the number of sides ($$6$$) the pattern can be extracted by running one of the convolutions, for example, for the sum, $$n = 4$$. Implementing the summation in the equation above, starting for the probability values to compute:

    d1        d2
k = 0     n-k = 4
k = 1     n-k = 3
k = 2     n-k = 2
k = 3     n-k = 1
k = 4     n-k = 0


we see that since we are working with fair dice, the probability for all compositions is going to naturally be $$\frac{1}{6}\cdot\frac{1}{6}=\frac{1}{36}$$, except for the multiplications including $$k = 0$$ or $$n-k=0$$, which indicate impossible situations (no zeros on the sides of the dice). Therefore only three of the five permutations on the table above will contribute to the convolution.

We can get a visualization of the zipper-like process of the convolution on the animation below:

This explains that for values of the sum including permutations of dice below $$7$$ (those corresponding to the physical sides) the equation in the OP calls for $$n-1$$. We "lose" one of the contributions due to the presence of a zero in the convolution.

The situation is slightly more complex when the total sum allows permutations that include dice results above those physically possible (i.e. greater than $$6$$). In this part of the convolutions that generate the PMF of the total sum, the counting will have to reflect that the probability of any dice showing values of 7, 8, 9, 10, 11 or 12 is 0. That, plus, the fact that the definition of the convolution includes a zero, hence, we are not counting 12, but 13. $$13 - n$$ will equal the remaining integers that will not be neutralized by a product in the sigma computation including a zero probability. Again, here is an animation with an example ($$n =11$$) (hover over or click on it):

And for the middle value of 7, either $$n-1$$ or $$13-n$$ will produce identical results.

I'm still working through the last part of my OP, but hopefully someone will address that part.