Generating functions and probability distributions
I was reminded recently about something that took me an embarrassingly long time to realise: that the binomial expansion and the binomial distribution were intrinsically linked.
I mean, sure, obviously they both have an nCr in them, but what of it? It’s just Pascal’s triangle.
And then someone mentioned generating functions in a way that made sudden sense to me, and I hope I can do the same for you.
Let’s start with a concrete example
Suppose we roll four standard six-sided dice and want to know how likely we are to throw any given number of sixes. That’s simple enough:
Sixes | Calculation | Probability |
0 | 0.482 | |
1 | 0.386 | |
2 | 0.116 | |
3 | 0.015 | |
4 | 0.001 |
Now, if we look at the binomial expansion of
… say look! Those calculations are identical. The coefficient of the
And this works in general – if you’ve got
Other distributions
It turns out, you can do just the same thing for the geometric distribution: given
What would our GF look like?
That looks a lot like, well, a geometric sequence. The first term is
And the Poisson? Well, if
If we write out the corresponding function, we get
Sanity checks and means
A quick sanity check for GFs is to see whether the probabilities sum to one – and that’s easy: just put in
There’s also a quick way to figure out means: if you differentiate the generating function and put in