Wednesday, 19 February 2014

Generating functions for random walk

Here is Mathematica code for the generating functions for the step at which the random walk first hits a barrier.
Uz(s)=n=0P(hit 0 at nstart at z)sn,
Vz(s)=n=0P(hit a at nstart at z)sn.

As one would expect, Uz(1)=qz, Vz(1)=pz and Uz(1)+Vz(1)=Dz.

I used these to compute the table on page 60 of the notes. You could use these to find the variance of the duration of the game. By the way, notice in this table that in lines 2-4 the duration of the game is 10 times the expected loss. This is because the expected loss per game is EX1=0.1. So we are seeing E[G]=E[X1++XN]=ENEX1=DzEX1, where the r.v. N is the length of the game.
L1[s_] = (1 + Sqrt[1 - 4 p q s^2])/(2 p s);
L2[s_] = (1 - Sqrt[1 - 4 p q s^2])/(2 p s);

U[s_] = (q/p)^z (L1[s]^(a - z) - L2[s]^(a - z))/(L1[s]^a - L2[s]^a) 
U[s] /. {a -> 10, z -> 9, p -> 45/100, q -> 55/100};
Series[%, {s, 0, 15}] // Simplify

M1[s_] = (1 + Sqrt[1 - 4 p q s^2])/(2 q s);
M2[s_] = (1 - Sqrt[1 - 4 p q s^2])/(2 q s);
V[s_] = (p/q)^(a - z) (M1[s]^z - M2[s]^z)/(M1[s]^a - M2[s]^a) 
V[s] /. {a -> 10, z -> 9, p -> 45/100, q -> 55/100};
Series[%, {s, 0, 15}] // Simplify

Comments

Loading... Logging you in...
  • Logged in as
There are no comments posted yet. Be the first one!

Post a new comment

Comments by