3 Generating functions

3.3 Solution of difference equations arising out of pgf

For the problem of the time until the first two successes in a Bernoulli process, we derived the recursion:

pi=qpi-1+pqpi-2,i3

in 3.2.2; where pi is the probability of this happening at time i, and p=1-q is the probability of a success. We are now going to consider how to solve equations like this.

Firstly note that to solve this equation we need some initial conditions. In our case we have p2=p2 and p1=0. We can see that given these two initial conditions the recursion will uniquely define pi for i3.

Proposition 3.3.1 (General Solution).

Consider a recursion of the sequence {xi} of the form

akxi+ak-1xi-1++a0xi-k=0. (3.1)

Let θ1,,θk be the roots of the auxiliary equation

akθk+ak-1θk-1++a1θ+a0=0.
  • (i)

    If all the roots are unique, the solution of (3.1) is

    xi=c1θ1i++ckθki,

    a linear combination of the powers of roots, where c1,,cn are arbitrary constants.

  • (ii)

    If the roots are not unique, with d distinct roots and distinct root θj having multiplicity mj, then the solution of (3.1) is

    xi=j=1dcj(i)θji,

    where cj(i) is a poylnomial of order mj-1 in i. This is still a linear combinations of the powers of roots but the coefficients are polynomials in ‘i’.

This can be proven by showing that these are solutions of (3.1), and noting that they have the correct number of independent constants.

Example 3.3.2 (Time until two successes).

If we consider the recursion for the time until two successes in a Bernoulli process:

pi=qpi-1+pqpi-2

and assume p=1/2. Can we solve for pi?

The auxillary equation is

θ2-12θ-14=0.

This gives roots

θ1=14+54,θ2=14-54

Thus the general solution is

pi=c1(1+54)i+c2(1-54)i.

We use the initial conditions to solve for c1 and c2:

0=c1(1+54)+c2(1-54)
14=c1(1+54)2+c2(1-54)2.

Solving gives

c1=25+5c2=25-5.

Thus

pi=25+5(1+54)i+25-5(1-54)i.
Example 3.3.3 (Simple Random Walk).

Consider the simple random walk with p=1/2. Assume X0=i. Calculate the probability, Pi that Xt=n before Xt=0. (A special case for this was done in Exercise 2.2.2).

Here we will see how we can solve the problem using difference equations. Firstly condition on the first event of the simple random walk:

Figure 3.5: Link, Caption: none provided

By conditioning we get

Pi=12Pi+1+12Pi-1,   1in-1.

For this problem we have boundary conditions: P0=0 and Pn=1.

Now the auxiliary equation is

12θ2-θ+12=0,
12(θ-1)2=0

The roots of this are θ1=θ2=1. Thus the general solution is

Pi=(c1+ic2)θ1i=(c1+ic2)

We use the boundary conditions to solve for c1 and c2. As P0=0, we get c1=0, and as Pn=1 we have c2=1/n. Thus

Pi=in.
Example 3.3.4.

We now consider a simple random walk with p=1/2, and X0=i. This time we want to calculate the expected time until Xt first hits either 0 or n. Denote this Ei.

Firstly condition on the first event of the simple random walk:

Figure 3.6: Link, Caption: none provided

Thus for i=1,,n-1:

Ei=12(1+Ei-1)+12(1+Ei+1)=1+12Ei-1+12Ei+1,

with boundary conditions

E0=En=0

We can rearrange the difference equation to

12Ei+1-Ei+12Ei-1=-1 (3.2)

The difference equation is different due to the constant on the right-hand side. To solve we first solve the homogeneous equation (with the right-hand side equal to 0). This is the same difference equation as in 3.3.3, and so we know the general solution

Ei=c1+c2i.

Now we need to guess a particular solution to (3.2) with -1 in the rhs. It is normal to try a solution that is polynomial in i of the same order as the polynomial on the right-hand side. However as our general solution is linear in i, we will try a solution which is quadratic: Ei=c3i2.

Substituting this we get

-1 =c32((i+1)2-2i2+(i-1)2)
=c32(i2+2i+1-2i2+i2-2i+1)
=c32(2)

So c3=-1

Thus our solution is

Ei=c1+c2i-i2.

We now use the boundary conditions to solve for c1 and c2:

Firstly E0=0, so we have c1=0.
Secondly we have En=0. Thus

0=c2n-n2c2=n.

Hence we have

Ei=i(n-i).