Professional Documents
Culture Documents
200 Markov Chains
200 Markov Chains
Alejandro Ribeiro
Dept. of Electrical and Systems Engineering
University of Pennsylvania
aribeiro@seas.upenn.edu
http://www.seas.upenn.edu/users/~aribeiro/
Classes of States
Limiting distributions
Ergodicity
i 1 i i +1
0.8 0.7
✓ ◆ 0.2
0.8 0.2
P :=
0.3 0.7 H S
0.3
I Inertia ) happy or sad today, likely to stay happy or sad tomorrow
(P00 = 0.8, P11 = 0.7)
I But when sad, a little less likely so (P00 > P11 )
0.9 HH 0.2 SH
0 1
0.9 0.1 0 0
B 0 0 0.4 0.6 C
B
P := @ C 0.8 0.6
0.8 0.2 0 0 A
0 0 0.3 0.7
0.4
HS SS 0.7
0.3
I More time happy or sad increases likelihood of staying happy or sad
I State augmentation ) Capture longer time memory
Stoch. Systems Analysis Markov chains 8
Random (drunkard’s) walk
I Step to the right with probability p, to the left with prob. (1-p)
p p p p
i 1 i i +1
1 p 1 p 1 p 1 p
Pi,i+1 = p, Pi,i 1 =1 p,
80 80 80
60 60 60
40 40 40
position (in steps)
0 0 0
I With p > 1/2 diverges to the right (grows unbounded almost surely)
I With p < 1/2 diverges to the left
I With p = 1/2 always come back to visit origin (almost surely)
I Because number of states is infinite we can have all states transient
I They are not revisited after some time (more later)
South or North
35
30
Latitude (North−South)
20
15
−10
⇥ ⇤ 1 50
⇥ ⇤ 1
Latitude (North−South)
P x(t +1) = i 1, y (t + 1) = j x(t) = i, y (t) = j = 20
4 10
⇥ ⇤ 1 0
⇥ ⇤ 1 −20
0 ... i 1 i i +1 ... J
1 p 1 p
I States 0 and J are called absorbing. Once there stay there forever
I The rest are transient states. Visits stop almost surely
Classes of States
Limiting distributions
Ergodicity
I Define matrices P(m) with elements Pijm , P(n) with elements Pijn and
P(m+n) with elements Pijm+n
P1
I Pkjn Pikm is the (i, j)-th element of matrix product P(m) P(n)
k=1
I Chapman Kolmogorov in matrix form
P(2) = PP = P2
P(n) = P(n 1)
P = P(n 2)
PP = . . . = Pn
Theorem
The matrix of n-step transition probabilities P (n) is given by the n-th
power of the transition probability matrix P. i.e.,
P(n) = Pn
Henceforth we write Pn
⇥ ⇤
I All probabilities so far are conditional, i.e., P Xn = j X0 = i
I Want unconditional probabilities pj (n) := P [Xn = j]
I Requires specification of initial conditions pi (0) := P [X0 = i]
p(n) = Pn T p(0)
✓ ◆
I
0.8 0.2
Transition probability matrix ) P :=
0.3 0.7
p(0) = [1, 0] p(0) = [0, 1]
1 1
P(Happy) P(Happy)
0.9 P(Sad) 0.9 P(Sad)
0.8 0.8
0.7 0.7
0.6 0.6
Probabilities
Probabilities
0.5 0.5
0.4 0.4
0.3 0.3
0.2 0.2
0.1 0.1
0 0
0 5 10 15 20 25 30 0 5 10 15 20 25 30
Time (days) Time (days)
Classes of States
Limiting distributions
Ergodicity
0 ... i 1 i i +1 ... N
q q
I Sates 0 and N said absorbing. Eventually end up in one of them
I Remaining states said transient (visits eventually stop)
I Being absorbing states says something about the limit wealth
⇣ ⌘
lim xn = 0, or lim xn = N, ) Si := P lim Xn = N X0 = i
n!1 n!1 n!1
p(Si+1 Si ) = q(Si Si 1)
Si+1 Si = ↵(Si Si 1)
1 ↵i
Si = S1
1 ↵
I Write for i = 1. When in state N, SN = 1
1 ↵N
1 = SN = S1
1 ↵
I Compute S1 from latter and substitute into expression for Si
1 ↵i
Si =
1 ↵N
I For ↵ < 1, Pi ! 1 ↵i
I If win prob. exceeds loose probability might win
I If initial wealth i sufficiently high, will most likely win
) Which explains what we saw on first lecture and homework
Classes of States
Limiting distributions
Ergodicity
qn+1 = qn + An , if qn = 0
P [An = 1] = , P [Dn = 1] = µ
1 1 µ 1 ⌫ 1 µ
0 ... i 1 i i +1 ...
µ µ µ
I
0
10
queue length 0 Propagate probabilities with
queue length 10
queue length 20
product Pn p(0)
−1
I Probabilities obtained are
10
⇥ ⇤
Probabilities
P qn = i q0 = 0 = pi (n)
−2
10
I A few i’s (0, 10, 20) shown
I Probability of empty queue ⇡ 0.1.
−3
10
0 100 200 300 400 500 600 700 800 900 1000
I Occupancy decrease with index
Time
Classes of States
Limiting distributions
Ergodicity
1 0.2 0.2
T1 R1 0.3
T2 R2 0.4
0.2 0.2
I State i is recurrent if fi = 1
I Process reenters i again and again (almost surely). Infinitely often
⇥ ⇤
I State R3 is recurrent because P X1 = R3 X0 = R3 = 1
1 0.2 0.2
T1 R1 0.3
I State R1 is recurrent because
R3 0.6 0.6 0.6 0.7
⇥ ⇤
P X1 = R1 X0 = R1 = 0.3 T2 R2 0.4
⇥ ⇤ 0.2 0.2
P X2 = R1 , X1 6= R1 X0 = R1 = (0.7)(0.6)
⇥ ⇤
P X3 = R1 , X2 6= R1 , X1 6= R1 X0 = R1 = (0.7)(0.4)(0.6)
..
.
⇥ ⇤
P Xn = R 1 , Xn 1 6= R1 , . . . , X1 6= R1 X0 = R1 = (0.7)(0.4)n 1
(0.6)
1
X ⇥ ⇤
I Sum up: fi = P Xn = R1 , Xn 1 6= R1 , . . . , X1 6= R1 X0 = R1
n=1
1
! ✓ ◆
X n 1 1
= 0.3 + 0.7 0.4 0.6 = 0.3 + 0.7 0.6 = 1
n=1
1 0.4
1 0.2 0.2
T1 R1 0.3
T2 R2 0.4
0.2 0.2
1 0.2 0.2
T1 R1 0.3
T2 R2 0.4
0.2 0.2
I Partitions set of states into disjoint classes (as all equivalences do)
I What are these classes? (start with a brief detour)
P [Ni = n] = fi n (1 fi )
Theorem
P1
I State i is transient if and only if n=1 Piin < 1
P1
I State i is recurrent if and only if n=1 Piin = 1
Theorem
If state i is recurrent and i $ j, then j is recurrent
Proof.
I If i $ j then there are l, m such that Pjil > 0 and Pijm > 0
I Then, for any n we have
1 1 1
!
X X X
Pjjl+n+m Pjil Piin Pijm = Pjil Piin Pijm = 1
n=1 n=1 n=1
Corollary
If state i is transient and i $ j then j is transient
Proof.
I If j were recurrent, then i would be recurrent from previous theorem
1 0.2 0.2
T1 R1 0.3
T2 R2 0.4
0.2 0.2
I Three classes
) T := {T1 , T2 }, class with transient states
) R1 := {R1 , R2 }, class with recurrent states
) R2 := {R3 }, class with recurrent states
Classes of States
Limiting distributions
Ergodicity
0 1 2
1 1
I State 1 has period 2. So do 0 and 2 (class property)
I One dimensional random walk also has period 2
I Ergodic states are those that are positive recurrent and aperiodic
I An irreducible MC with ergodic states is said to be an ergodic MC
Theorem
For an irreducible ergodic MC, limn!1 Pij exists and is independent of
the initial state i. That is
⇡ = PT ⇡, ⇡T 1 = 1
I PT ⇡ = 0 ⇡T 1 = 1
Classes of States
Limiting distributions
Ergodicity
0.5
ergodic averages
number of visits
15
0.4
10
0.3
0.2
5
0.1
0 0
0 5 10 15 20 25 30 35 40 0 10 20 30 40 50 60 70 80 90 100
time time
(n)
I Use of ergodic averages is more general than Ti
Theorem
Consider an irreducible Markov chain with states Xn = 0, 1, 2, . . . and
stationary probabilities ⇡j . Let f (Xn ) be a bounded function of the state
X (n). Then, with probability 1
n 1
1X X
lim f (Xm ) = f (i)⇡i
n!1 n
m=1 i=1
(n)
I Ti is a particular case with f (Xm ) = I {Xm = i}
Proof.
I Because I {Xm = i} = 1 if and only if Xm = i we can write
n n 1
!
1X 1X X
f (Xm ) = f (i)I {Xm = i}
n m=1 n m=1
i=1
(n)
I Change order of summations. Use definition of Ti
n 1 n
! 1
1X X 1X X (n)
f (Xm ) = f (i) I {Xm = i} = f (i)Ti
n m=1 n m=1
i=1 i=1
(n) (n)
Visits to states, nTi Ergodic averages, Ti
25 0.8
State −1 State −1
State 0 State 0
State 1 0.7 State 1
20
0.6
ergodic averages
0.5
number of visits
15
0.4
10
0.3
0.2
5
0.1
0 0
0 5 10 15 20 25 30 35 40 0 10 20 30 40 50 60 70 80 90 100
time time
(n)
I Ergodic averages Ti converge to the ergodic limits ⇡i
I Limit probabilities for transient states are null P [Xn = i] ! 0, for all
X n 2 Tk
1 0.2 0.2
0 1 1 3
0 0.6 0.2 0 0.2
B 0.6 0 0 0.2 0.2 C
B C 5 0.6 0.6 0.6 0.7
P := B
B 0 0 0.3 0.7 0 C
C
@ 0 0 0.6 0.4 0 A 2 4
0 0 0 0 1 0.2 0.2
0.4
I States 1 and 2 are transient T = {1, 2}
I States 3 and 4 form an ergodic class E1 = {3, 4}
I State 5 is a separate ergodic class E2 = {5}
Classes of States
Limiting distributions
Ergodicity
1 1 µ 1 ⌫ 1 µ
0 ... i 1 i i +1 ...
µ µ µ
0.09
−2
0.08 10
0.07
Limiting probabilities
Limiting probabilities
−3
0.06 10
0.05
−4
0.04 10
0.03
−5
0.02 10
0.01
−6
0 10
0 10 20 30 40 50 60 70 80 90 100 0 10 20 30 40 50 60 70 80 90 100
state state
1 1 µ 1 ⌫ 1 µ
0 ... i 1 i i +1 ...
µ µ µ
⇡0 = (1 )⇡0 + µ⇡1
⇡ i = ⇡i 1 + (1 µ)⇡i + µ⇡i+1
c↵i = c↵i 1
+ (1 µ)c↵i + µc↵i+1
µ↵2 ( + µ)↵ + =0
P1
I Determine c so that probabilities sum 1 ( ⇡i = 1)
i=0
1
X J
X c
⇡i = c( /µ)i = =1
1 /µ
i=0 i=0
1 1 µ 1 ⌫ 1 µ
0 ... i 1 i i +1 ...
µ µ µ
(1 )+ ⌫ ⌫ ⌫ ⌫
(1 µ) (1 µ) (1 µ) (1 µ)
0 ... i 1 i i +1 ...
µ(1 ) µ(1 ) µ(1 )
(1 µ)
(1 µ)c = µ(1 )c↵ ) ↵=
µ(1 )
(1 )+ ⌫ ⌫ ⌫ ⌫ + (1 µ)(1 )
(1 µ) (1 µ) (1 µ) (1 µ)
0 ... i 1 i i +1 ... J
25
20
15
queue length
10
0
0 100 200 300 400 500 600 700 800
time(s)
60 states 20 states
−1
10
limit probs limit probs
ergodic average ergodic average
−1
−2 10
10
Limit probabs/ergodic average
−4
10
−5 −2
10 10
0 10 20 30 40 50 60 0 2 4 6 8 10 12 14 16 18 20
state state
I If = 0.45 and µ = 0.55 how many packets the bu↵er needs to hold
to have a drop rate smaller than 10 6 (one packet dropped for every
million packets handled)