Generating Function

A generating function is essentially a summary for a sequence of numbers. It's a formal power series where the coefficients encode a sequence of numbers, a0,a1,a2,.
The ordinary generating function for a sequence {an}n=0 is the power series:

G(z)=n=0anzn

There is also a continuous analogue. If instead of a sequence one has a function f(x), the discrete sum can be replaced by an integral:

G(z)=0f(x)zxdx.

This plays the role of a continuous generating function, directly paralleling the discrete case.
When one reparametrizes with z=es, this construction becomes the Laplace transform:

G(es)=0f(x)esxdx,

and related choices of weighting lead to other transforms such as the Mellin transform.

Application in probability theory

For a discrete random variable X that takes non-negative integer values {0,1,2,}, we can define a Probability Generating Function (PGF). Here, the sequence of numbers is the probability mass function (PMF) of X, where pk=P(X=k).

The PGF of X is defined as:

GX(z)=E[zX]=k=0P(X=k)zk=k=0pkzk

Sum of independent random variables

This is where the magic happens. If you have two independent discrete random variables, X and Y, and you define a new variable S=X+Y, the PGF of the sum S is simply the product of the individual PGFs.

GS(z)=GX+Y(z)=GX(z)GY(z)

This is incredibly useful because multiplying polynomials (or power series) is often much simpler than dealing with the distribution of the sum directly.

Relation to convolution

The process of finding the probability distribution of the sum of two independent random variables is equivalent to computing the convolution of their individual probability distributions.
Let P(X=k)=pk and P(Y=k)=qk. The PMF of the sum S=X+Y is given by the discrete convolution of the sequences {pk} and {qk}:

P(S=n)=k=0nP(X=k)P(Y=nk)=k=0npkqnk

This sum is precisely the coefficient of the zn term when you multiply the two power series GX(z) and GY(z) together.
In short: multiplication of generating functions corresponds to the convolution of their coefficient sequences.