# Probability-generating function

In probability theory, the **probability-generating function** of a discrete random variable is a power series representation (the generating function) of the probability mass function of the random variable. Probability-generating functions are often employed for their succinct description of the sequence of probabilities Pr(*X* = *i*), and to make available the well-developed theory of power series with non-negative coefficients.

## Contents

## Definition

If *N* is a discrete random variable taking values on some subset of the non-negative integers, {*0,1, ...*}, then the *probability-generating function* of *N* is defined as:

where *f* is the probability mass function of *N*. Note that the equivalent notation *G*_{N} is sometimes used to distinguish between the probability-generating functions of several random variables.

## Properties

### Power series

Probability-generating functions obey all the rules of power series with non-negative coefficients. In particular, *G*(1^{-}) = 1, since the probabilities must sum to one, and where *G*(1^{-}) = lim_{z→1}*G*(*z*) from below. So the radius of convergence of any probability-generating function must be at least 1, by Abel's theorem for power series with non-negative coefficients.

### Probabilities and expectations

The following properties allow the derivation of various basic quantities related to *X*:

1. The probability mass function of *X* is recovered by taking derivatives of *G*

2. It follows from Property 1 that if we have two random variables *X* and *Y*, and *G*_{X} = *G*_{Y}, then *f*_{X} = *f*_{Y}. That is, if *X* and *Y* have identical probability-generating functions, then they are identically distributed.

3. The normalization of the probability density function can be expressed in terms of the generating function by

The expectation of *X* is given by

More generally, the *k*th factorial moment, E(*X*(*X* − 1) ... (X − k + 1)), of *X* is given by

So the variance of *X* is given by

4.*G*_{X}() = *M*_{X}(t) where *X* is a random variable, G(t) is the probability generating function and M(t) is the moment generating function.

### Functions of independent random variables

Probability-generating functions are particularly useful for dealing with functions of independent random variables. For example:

- If
*X*_{1},*X*_{2}, ...,*X*_{n}is a sequence of independent (and not necessarily identically distributed) random variables, and

- where the
*a*_{i}are constants, then the probability-generating function is given by

- For example, if

- then the probability-generating function,
*G*_{Sn}(*z*), is given by

- It also follows that the probability-generating function of the difference of two random variables
*S*=*X*_{1}−*X*_{2}is

- Suppose that
*N*is also an independent, discrete random variable taking values on the non-negative integers, with probability-generating function*G*_{N}. If the*X*_{1},*X*_{2}, ...,*X*_{N}are independent*and*identically distributed with common probability-generating function*G*_{X}, then

- This can be seen as follows:

- This last fact is useful in the study of Galton-Watson processes.

- Suppose again that
*N*is also an independent, discrete random variable taking values on the non-negative integers, with probability-generating function*G*_{N}. If the*X*_{1},*X*_{2}, ...,*X*_{N}are independent, but*not*identically distributed random variables, where denotes the probability generating function of , then it holds

- For identically distributed
*X*this simplifies to the identity stated before. The general case is sometimes useful to obtain a decomposition of_{i}*S*by means of generating functions._{N}

## Examples

- The probability-generating function of a constant random variable, i.e. one with Pr(
*X*=*c*) = 1, is

- The probability-generating function of a binomial random variable, the number of successes in
*n*trials, with probability*p*of success in each trial, is

- Note that this is the
*n*-fold product of the probability-generating function of a Bernoulli random variable with parameter*p*.

- The probability-generating function of a negative binomial random variable, the number of trials required to obtain the
*r*th success with probability of success in each trial*p*, is

- Note that this is the
*r*-fold product of the probability generating function of a geometric random variable.

- The probability-generating function of a Poisson random variable with rate parameter λ is

## Example calculation: use of bivariate generating functions

The following example illustrates a very common technique the manipulation of PGFs: the use of bivariate super generating functions to compute the OGF of the PGFs of a sequence of random variables.

Suppose you sample a system that can assume two states, *X* and *Y*, *X* with probability *p* and *Y* with probability *1-p*, e.g. a coin being flipped, obtaining the sequence of samples

where the system was sampled *n* times and has no memory.

Define the random variable to be the number of changes from one sample to the next in a sequence of *n* samples, i.e. how often was different from . For example, the sequence

has two changes, as does

We want to calculate the PGF of , which we will do by using bivariate generating functions.

We introduce the bivariate GF given by

i.e. is the ordinary generating function of the PGFs of the This step is completely general and indeed the core of the method.

Now let be the probability of having *k* changes in a sequence of *n* samples, where the last sample was an *X*. Similarly, let be the probability of having *k* changes in a sequence of *n* samples, where the last sample was a *Y*, and put

so that

Now we clearly have

because having zero changes means getting a sequence of all *Xs* or *Ys.*

For we find

because e.g. to have *k* changes in a sequence of length *n* that ends in *X*, we either append an *X* to a sequence having *k-1* changes and ending in *Y*, or append an *X* to a sequence having *k* changes and ending in *X*.

Summing these equations over *n* and *k* and writing *X* for *X(z, u)* and *Y* for *Y(z, u)*, we obtain

and

The solution of this system is

and

We may now use the general identity

to calculate the factorial moments of E.g. the OGF of the expectations is given by

from which we find (extracting coefficients) that

An extensive discussion of this problem, as well as solutions by other methods,
may be found on *Les-Mathematiques.net*
(external links).

## Example calculation: bivariate generating functions and differential equations

Consider the following balls and urns problem: suppose we have an urn containing *n* distinguishable balls, i.e. bearing labels from *1* to *n*. We pick one of the balls at random and remove it from the urn. We also remove all balls whose labels are larger than the one we picked from the urn. E.g. if we picked ball number one, the urn is emptied after one operation. We repeat until the urn is empty. E.g. for an urn containing ten balls, the sequence of picks 6-3-1 would empty the urn in three operations. We introduce the random variable , which gives the number of picks needed to empty the urn. Our goal is to compute all of its moments, and we will do so using exactly the same bivariate generating function as in the previous example, namely the OGF of the PGFs:

We let be the probability of emptying an urn containing *n* balls with *k* operations, so that

We find that

because to empty the urn with one operation, we must pick the ball labelled *1*. The remaining probabilities are computed recursively, e.g. we pick the ball with the largest label with probability , leaving balls (this is ). We pick the ball with the next-to-largest label with probability , leaving balls (this is ), etc. The upper bound for *r* is , because we must have (we cannot e.g. empty an urn containing six balls using seven operations).

Next we set for , so that we may replace the recursion by

Using the coefficient-extraction operator for formal power series, we thus have

We note furthermore that

and that

where the first equation results from our "boundary condition" that the probability of emptying an urn with one operation is

Summing over (there are two contributions to both sides of the equation, one for and another one for ), we obtain

e.g. through

The solution to the differential equation is

- ,

with a formal power series in *u*. We note

which follows from the formal series

Hence is constant and equal to one, and we finally have

which is, incidentally, the generating function of the Stirling numbers of the first kind.

The moments now follow trivially from the formula given in the first example. E.g. for the expectation, we find

which gives

the *n*th harmonic number, and we need about operations to empty the urn.

An extensive discussion of this problem, as well as solutions by other methods,
may be found on *Les-Mathematiques.net*
(external links).

## Related concepts

The probability-generating function is occasionally called the z-transform of the probability mass function. It is an example of a generating function of a sequence (see formal power series).

Other generating functions of random variables include the moment-generating function and the characteristic function.

## External links

de:Wahrscheinlichkeitserzeugende_Funktion fa:تابع مولد احتمال nl:Kansgenererende functie