3 Generating functions

3.2 Using pgfs to analyse stochastic processes

We now apply the method of generating functions to solve problems in stochastic processes.

Example 3.2.1.

What is the distribution of the time T at which two successes in a row first occur in Bernoulli trials.

We use the same tree of possibilities at the start of the process to define the rv V and obtain G(z), the pgf of T, by conditioning on V.

Figure 3.2: Link, Caption: none provided

Using E(U)=E[E(U|V)] with U=zT gives

G(z)=E(zT)=E(zT|V=1)q+E(zT|V=2)pq+E(zT|V=3)p2

where, as in Chapter 2,

if V = {123 then T = {1+T2+T′′2

So, remembering that z is just a number,

G(z)=E(z1+T)q+E(z2+T′′)pq+E(z2)p2
=zE(zT)q+z2E(zT′′)pq+z2p2.

Again we use the fact that T and T′′ have the same distribution as T, so that they also have the same pgf G(z) which therefore satisfies (dropping the argument z for convenience):

G=zGq+z2Gpq+z2p2

or

(1-qz-pqz2)G=z2p2

so that

G(z)=z2p21-qz-pqz2.
Method 3.2.2 (How to use this result).

First, we expand G(z) by a method which works for the ratio of any two polynomials, first multiplying out:

(1-qz-pqz2)(p0+p1z+p2z2++pizi+)=p2z2

and then equating coefficients of powers of z to get, for

z0:p0=0z1:p1-qp0=0p1=0z2:p2-qp1-pqp0=p2p2=p2z3:p3-qp2-pqp1=0p3=qp2+pqp1=p2qz4:p4-qp3-pqp2=0p4=qp3+pqp2=qp2q+pqp2=p2qzi:pi-qpi-1-pqpi-2=0pi=qpi-1+pqpi-2,i3..

This last equation enables us to calculate each term in the pdf in succession from the previous two. It is a relationship which we could have derived directly without using the pgf argument, but the pgf does provide a reliable derivation.

Method 3.2.3 (How to find the moments of T).

For example to evaluate E(T)=G(1). Again multiply out and use implicit differentiation of both sides of:

(1-qz-pqz2)G=p2z2

to get

(1-qz-pqz2)G+(-q-pq2z)G=p22z

and set z=1, remembering that G(1)=1 since T is proper,

(1-q-pq)E(T)+(-q-2pq)1=2p2

from which

E(T)=q+2pq+2p21-q-pq=1+pp2

after simplifying to get the same answer as before.

Exercise 3.2.4.

Calculate the pgf of the time T until a simple random walk, started at X0=1 first reaches either 0 or 3.

Figure 3.3: Link, Caption: none provided

So

G(z)=z2p2+z2G(z)pq+zq

and hence

G(z)=z2p2+zq1-z2pq
Theorem 3.2.5.

Let the rv T be the time to ruin in a RW starting from X0=1. Then the pgf G(z) of T satisfies

pzG2-G+qz= 0.
Proof.

Condition on the first step and consider

Figure 3.4: Link, Caption: none provided
G(z)=E(zT)=E[E(zT|X1)]=E(zT|X1=2)P(X1=2)+E(zT|X1=0)P(X1=0).

Using the same notation as in Theorem 2.2.5:

if X1={20 then T={1+T21 with probability {pq

so that

G(z)=E(z1+T2)p+zq=zE(zT2)p+zq.

Now consider T2, the further time to ruin from X1=2. This has exactly the same distribution as T2, the time to ruin from X0=2. Further,

T2=L1+L2,

the sum of the lengths of the first two games, which are independent rvs each with the same distribution as T, and therefore the same pgf G(z). Hence

E(zT2)=GT2(z)=G(z)2,

giving

G(z)=zG(z)2p+zq

as required. ∎

Remark.

We have not explicitly taken account of the fact that T may not be a proper rv.

There is no difficulty on this point if we consider the definition of G(z) as the power series p0+p1z+p2z2+, because the first proof presented in Proposition 3.1.2(c) for the pgf of sums of random variables does not require the rvs to be proper; it just represents the relationship between the probabilities of the rvs taking different, finite, values.

Corollary 3.2.6.

Solving the quadratic equation gives

G(z)=1-(1-4pqz2)122pz.

We have eliminated the solution [1+(1-4pqz2)12]/2pz because it gives G(z) as z0 whereas the other one is 0/0 form with a limit.

To obtain the pmf, e.g. in the case p=12, we expand

(1-z2)12=1+12(-z2)+12(12-1)(-z2)2/2+

so

G(z)=1-(1-z2)12z=12z+18z3+

giving p1=12, p3=18, ….

Note that P[T<]=1/2+1/8+.

Method 3.2.7.

To derive the moments of G(z), in the case when T is proper i.e. p1/2, we find G(z) by implicit differentiation of

G(z)=zG(z)2p+zq

giving

G(z)=z2G(z)G(z)p+G(z)2p+q.

Setting z=1, G(1)=1 (since T is proper) and G(1)=μ gives

μ=2μp+p+q(1-2p)μ=1μ=1/(1-2p).