Write a die as a polynomial, one power of per face. Watch the polynomial multiply by itself: its numbers become the chances of two dice.
Adding dice by multiplying
The polynomial of one die, multiplied by itself: its numbers are the chances of the total.
One die: (z + z^2 + z^3 + z^4 + z^5 + z^6)/6. Each power of z is a face, and its number, 1/6, is that face's chance.
Describe this picture
Bars of the numbers of a polynomial, one bar for each power of , on an axis of powers from 0 to 36 and numbers from 0 to 0.2, the tallest labelled with its value. The clip opens on one die, , written in the caption: six bars of height . The polynomial is multiplied by itself and the bars change into the triangle of two dice, from to with the tallest bar, , at . It is multiplied once more, for three dice: the bars run from to , and the two tallest, , are at and . Readouts give the number of dice , the mean and the variance . When the clip has finished, a slider, “Number of dice, n”, sets from 1 to 6, and the caption gives the range of powers, the tallest bar, the mean and the variance.
A die as a polynomial
On the page Sums of random variables, the chances of a two-dice total came from sliding one die’s chances along the other’s: a convolution. That works, but it is slow to do by hand, and slower for three dice. Here is a trick that does it by ordinary multiplication.
Write the chances of a die as the numbers in front of the powers of a letter , one power per face:
The letter is only a place-holder: the power says which face, and the number in front says its chance. Now multiply by itself. A term from the first copy times a term from the second gives : the powers add, as the faces do. So the number in front of in collects every pair of faces that adds up to 7. There are six of them, so it is , the chance of a total of 7.
Multiplying the polynomials did the convolution for me. That is the picture at the top of the page.
The generating function
For any random variable that takes whole-number values , the generating function is
The second form says the same thing: it is the mean of . A coin that lands heads () with chance has . Putting adds up all the chances, so for every .
The product rule. If and are independent, then
The third step uses independence: the mean of a product of independent variables is the product of their means. So adding independent variables multiplies their generating functions. For coin flips, the number of heads has , the generating function of .
A common slip is to add the generating functions instead. Adding them does not describe a sum of variables at all.
Moments from derivatives
The generating function also holds the mean and variance. Differentiate:
Differentiate again and put : . Since and ,
For one die, and . So the variance is , which is , the die’s variance.
For dice, gives mean and variance , as the readouts show when you drag the number of dice after the clip. With three dice, the mean is 10.5 and the variance is 8.75.
Two relatives
The same idea works with other functions in place of .
The moment generating function is . It is the generating function with , and it works for variables that are not whole numbers. Its derivative at is the mean.
The characteristic function is , where is the square root of , as in the signal processing pages. It always exists, even when does not, and it is the tool behind the usual proof of The central limit theorem. The product rule holds for both: adding independent variables multiplies their functions.
Worked example
- One die. , , variance .
- Two dice. The number in front of in is ; in front of it is .
- Three dice. The chances of 10 and of 11 are both . The mean is 10.5 and the variance 8.75.
- A coin. , so , the mean.
- Binomial. flips: .
- Always. .
Where you’ll meet this
Generating functions turn counting problems into algebra: how many ways a total can be made from coins or dice, for example. They give the chance that a family name dies out, where each person has a random number of children and the generating function of the whole tree is built by substituting one generating function into another. And they give exact distributions of sums where simulation gives only estimates.
In signal processing · transforms of a pmf
A pmf is a list of numbers, like a signal. Its generating function is the z-transform of The z-transform with replaced by : signal processing writes where this page writes . Its characteristic function is the DTFT of The DTFT evaluated at , because the DTFT uses . In both worlds, convolving two lists multiplies their transforms.
Reference card
| Quantity | Formula | Notes |
|---|---|---|
| Generating function | whole-number | |
| Always | the chances add to 1 | |
| Sum | independent , | |
| Mean | ||
| Variance | ||
| Coin, binomial | ; | |
| Moment generating | ||
| Characteristic | the DTFT of the pmf at |