Discrete-Time Markov Chains: He Shuangchi
Discrete-Time Markov Chains: He Shuangchi
Discrete-Time Markov Chains: He Shuangchi
He Shuangchi
Example
The NUS Co-op sells a specific model of laptop computers. Assume that
the weekly demands are iid following distribution
d 0 1 2 3 4
P[Dn = d] 0.3 0.3 0.2 0.1 0.1
where Dn is the demand of week n. By the end of each week, if the
inventory is less than or equal to 1, the store orders more to bring the
inventory back to 4 by the beginning of next week. Assume that all unmet
demand will be lost. Let Xn be the inventory level at the beginning of
week n. If X0 = 4, find E[X10 ].
Example
Let Yi be the highest IBM stock price on day i. Then, {Y0 , Y1 , . . .} is
a discrete-time stochastic process.
Let Y (t) be the IBM stock price at time t on a specific day. Then,
{Y (t) : t ≥ 0} is a continuous-time stochastic process.
IE5004 Discrete-Time Markov Chains 3 / 61
State space of a stochastic process
Definition
The set of all possible values that a random variable in a stochastic
process can take is called the state space of the stochastic process.
Question
What is the state space of X ?
Observation
Once the value of Xn is known, the distribution of Xn+1 no longer depends
on Xn−1 , Xn−2 , . . ..
Definition
A sequence of random variables {X0 , X1 , . . .} with state space S is called a
discrete-time Markov chain if for all n = 0, 1, . . . and all i0 , . . . , in , j ∈ S,
At any time n, the future state of the Markov chain Xn+1 depend on
the history X0 , . . . , Xn only through the present state Xn .
If a discrete-time stochastic process X can be expressed by
Xn+1 = f (Xn , Yn )
Definition
A discrete-time Markov chain {X0 , X1 , . . .} is called time-homogeneous if
for all n = 0, 1, . . . and all i, j ∈ S,
Question
Find the transition probabilities of X in the laptop example.
Question
In the laptop example, find the distribution of X1 .
P = [Pij ]i,j∈S
Example
The transition matrix of the laptop example is given by
2 3 4
2 0.3 0 0.7
P = 3 0.3 0.3 0.4
4 0.2 0.3 0.5
1 2 ··· j ··· m
1 P11 P12 ··· P1j ··· P1m
2 P21 P22 ··· P2j ··· P2m
.. .. .. .. .. .. ..
. . . . . . .
P=
i Pi1 Pi2 ··· Pij ··· Pim
.. .. .. .. .. .. ..
. . . . . . .
m Pm1 Pm2 ··· Pnj ··· Pmm
0.3
0.7 4 0.4
0.5
0 1 2 3 4 5 6
Question
In the laptop example, find the distribution of X2 .
Clearly,
and
where
(2)
Pij = P[Xn+2 = j|Xn = i] = P[X2 = j|X0 = i]
You may have already seen that
P (2) = P × P = P 2
Definition
Let {X0 , X1 , . . .} be a time-homogeneous Markov chain with state space
S = {1, . . . , m}. The k-step transition matrix of X is
1 2 ··· j ··· m
(k) (k) (k) (k)
1 P P12 ··· P1j ··· P1m
11
2 P (k) (k)
P22 ···
(k)
P2j ···
(k)
P2m
21
..
... .. .. .. .. ..
. .
P (k) = . (k)
.
(k)
.
(k)
.
(k)
i Pi1 Pi2 ··· Pij ··· Pim
.. ..
.. .. .. .. ..
. . . . . . .
(k) (k) (k) (k)
m Pm1 Pm2 ··· Pnj ··· Pmm
where
(k)
Pij = P[Xn+k = j|Xn = i] = P[Xk = j|X0 = i]
or equivalently,
P (k+`) = P (k) P (`)
The Chapman–Kolmogorov equations are equivalent to
P (k) = P k for k = 1, 2, . . .
Exercise
In the laptop example, find P[X6 = 2, X3 = 3, X1 = 2|X0 = 4].
P[X6 = 2, X3 = 3, X1 = 2|X0 = 4]
= P[X1 = 2|X0 = 4]P[X6 = 2, X3 = 3|X1 = 2, X0 = 4]
= P[X1 = 2|X0 = 4]P[X6 = 2, X3 = 3|X1 = 2]
= P[X1 = 2|X0 = 4]P[X3 = 3|X1 = 2]P[X6 = 2|X3 = 3, X1 = 2]
= P[X1 = 2|X0 = 4]P[X3 = 3|X1 = 2]P[X6 = 2|X3 = 3]
2 3
= P42 P23 P32
Example
In the laptop example, if X0 = 4, find E[X10 ].
Example
In the laptop example, suppose that X0 follows the distribution below
j 2 3 4
P[X0 = j] 0.5 0.2 0.3
Find the distribution of X3 .
Let
(0) (0) (0)
µ(0) = (µ2 , µ3 , µ4 ) = (0.5, 0.2, 0.3)
be the initial distribution. First,
Write
(3) (3) (3)
µ2 = P[X3 = 2], µ3 = P[X3 = 3], µ4 = P[X3 = 4]
(3) (3) (3)
Let µ(3) = (µ2 , µ3 , µ4 ) be the distribution of X3 . Then,
Proposition
For a time-homogeneous Markov chain {X0 , X1 , . . .} with state space
S = {1, . . . , m} and transition matrix P. Let
(k) (k)
µ(k) = (µ1 , . . . , µm )
(k)
be the distribution of Xk , i.e., µj = P[Xk = j] for k = 0, 1, . . . and
j = 1, . . . , m. Then,
µ(k) = µ(0) P k
Example
In the laptop example, suppose that the initial state X0 follows the
distribution below
j 2 3 4
P[X0 = j] 0.5 0.2 0.3
Find the distribution of X10 .
0.2473 0.2258 0.5269
µ(10) = µ(0) P 10
= 0.5 0.2 0.3 0.2473 0.2258 0.5269
0.2473 0.2258 0.5269
= (0.2473, 0.2258, 0.5269)
Question
Can we obtain the distribution of X10 if we do not know µ(0) ?
IE5004 Discrete-Time Markov Chains 27 / 61
Distribution after many steps of transitions
Observation
Each column of the ten-step transition matrix has “identical” entries
0.2473 0.2258 0.5269
P 10 = 0.2473 0.2258 0.5269
0.2473 0.2258 0.5269
The entries in the same column are not exactly the same, but the
difference is very small.
After a number of transitions, the distribution of the state becomes
independent of the initial distribution.
Observation
Using Matlab we can check that
0.2473 0.2258 0.5269
P 10 ≈ P 11 ≈ · · · = 0.2473 0.2258 0.5269
0.2473 0.2258 0.5269
As a result,
Definition
Let {X0 , X1 , . . .} be a Markov chain with state space S = {1, . . . , m} and
transition matrix P. A probability distribution µ = (µ1 , . . . , µm ) is called
the limit distribution of the Markov chain if
µ(10) P ≈ µ(10)
Definition
Let {X0 , X1 , . . .} be a Markov chain with state space S = {1, . . . , m} and
transition matrix P. A probability distribution π = (π1 , . . . , πm ) is called a
stationary distribution of the Markov chain if
πP = π
π1 + · · · + πm = 1 and πj ≥ 0 for j = 1, . . . , m
Proposition
If a Markov chain has a limit distribution π, then π must also be a
stationary distribution of the Markov chain.
Example
In the laptop example, find the distribution of X10 .
We can arbitrarily remove one of the first three equations, say, the third
one. Then, we have
0.3π2 + 0.3π3 + 0.2π4 = π2
0.3π3 + 0.3π4 = π3
π2 + π3 + π4 = 1
Example
In the laptop example, the weekly demand follows the distribution below
d 0 1 2 3 4
P[Dn = d] 0.3 0.3 0.2 0.1 0.1
Suppose that a $50 holding cost is incurred for each unsold laptop at the
end of a week. When placing an order, the store pays $1000 for each
computer and sells it at $1200. All unfulfilled demand will be lost. What is
the long-run average profit per week?
Let fj be the expected weekly profit if there are j laptops at the beginning
of the week. Then,
f2 = 0.3 × 2 × (−50) + 0.3(1200 − 50 − 3 × 1000)
+ (0.2 + 0.1 + 0.1)(2 × 1200 − 4 × 1000)
= −1225
IE5004 Discrete-Time Markov Chains 36 / 61
Example
Similarly,
By π = πP,
πj = π1 P1j + · · · + πm Pmj
Example
In the Markov chain given below, find the stationary distribution.
2/3 0 1 2 3
2/3 2/3 1
Using the above “cuts” of sets, we have the following balance equations
1 2
π 0 = π1
3 3
1π = 2π
1 2
3 3
1
3 π2 = π3
π0 + π1 + π2 + π3 = 1
Question
For a Markov chain, does limk→∞ P[Xk = j|X0 = i] always exist?
1 2
1.0
(
0 for k even
P[Xk = 1|X0 = 2] =
1 for k odd
(
1 if k is even
P[Xk = 2|X0 = 2] =
0 if k is odd
Hence, limk→∞ P[Xk = 1|X0 = 2] does not exist.
IE5004 Discrete-Time Markov Chains 41 / 61
Limit distribution revisited
Question
For a Markov chain, if limk→∞ P[Xk = j|X0 = i] exists for i, j ∈ S, is this
limit probability always independent of the initial distribution?
1.0 1 2 1.0
0.7 3 0.3
Question
When will a Markov chain have a limit distribution that does not depend
on the initial distribution?
To answer this question, we need to check the properties of each state.
Consider a Markov chain with state space S and transition matrix P. Let
Definition
State j is said to be accessible from state i if Pijk > 0 for some k ≥ 0, and
we write i → j. Two states i and j accessible to each other are said to
communicate, and we write i ↔ j.
Exercise
The transition diagram of a Markov chain is given below. Suppose that all
indicated transitions have a positive probability.
1 3
Exercise
For the following Markov chain, is state 1 accessible from state 3? Do they
communicate? Is state 2 accessible from state 4? Do they communicate?
1 2
4 3
Definition
Two states that communicate are said to be in the same class, i.e., a class
is a set of states in which any two states communicate.
Definition
A Markov chain is said to be irreducible if all states communicate, i.e., the
state space contains only one class.
Exercise
Is the Markov chain on page 45 irreducible? Is the Markov chain on
page 46 irreducible?
Exercise
Consider a Markov chain that has transition matrix
0 1 0 0
1 0 0 0
P= 0 0 0 1
0 0 1 0
1 2
4 3
For all 0 ≤ p ≤ 1,
π = (p/2, p/2, (1 − p)/2, (1 − p)/2)
is a stationary distribution.
The stationary distribution is not unique.
Proposition
If a Markov chain is irreducible and has a finite state space, then it has a
unique stationary distribution.
IE5004 Discrete-Time Markov Chains 49 / 61
Period of a state
Definition
For a state j ∈ S, let
where gcd denotes the greatest common divisor. Then, d(j) is called the
period of state j. A state of period 1 is said to be aperiodic.
Example
What is the period of state 1 of the Markov chain below?
1.0
1 2
1.0
Exercise
What is the period of state 1 of the Markov chain below?
1 2
Proposition
Let d(i) be the period of state i. If i ↔ j, then d(i) = d(j).
Period is a class property, i.e., if one state has this property, then all
states in the same class has this property.
All states of an irreducible Markov chain have the same period.
If the period is 1, we say that the Markov chain is aperiodic; if the
period is greater than 1, we say that the Markov chain is periodic.
Periodic Markov chains cannot have a limit distribution.
i.e., with probability 1, the Markov chain starting from state j will go back
to state j. State j is said to be transient if it is not recurrent.
Starting with a recurrent state j, the Markov chain will visit state j
infinite times.
A transient state can only be visited finite times, i.e., if state j is
transient,
lim Pijk = 0 for all i ∈ S
k→∞
Exercise
List recurrent and transient states for the examples on pages 45 and 46.
Definition
A recurrent state j is said to be positive recurrent if
Exercise
In the following Markov chain, is state 1 positive recurrent?
0.5
0.5 1 2
1.0
Because
P[τ1 = 1|X0 = 1] = P[X1 = 1|X0 = 1] = 0.5
P[τ1 = 2|X0 = 1] = P[X2 = 1, X1 6= 1|X0 = 1] = 0.5 × 1 = 0.5
and it is not possible that τ1 > 2. Hence,
E[τ1 |X0 = 1] = 0.5 × 1 + 0.5 × 2 = 1.5
State 1 is positive recurrent.
IE5004 Discrete-Time Markov Chains 55 / 61
Class properties
Proposition
An irreducible Markov chain that has a finite state space must be positive
recurrent.
Exercise
Is the Markov chain on page 45 positive recurrent? Is the Markov chain on
page 46 positive recurrent?
Theorem
Let {X0 , X1 , . . .} be an irreducible, aperiodic Markov chain with state
space S and transition matrix P. Assume that the Markov chain has a
stationary distribution π, i.e.,
X
πP = π, πj = 1, πj ≥ 0
j∈S
Then,
1 the Markov chain is positive recurrent;
2 π is a limit distribution, i.e.,
Example
Consider the following Markov chain that has an infinite state space
S = {0, 1, . . .}. Is it positive recurrent?
2/3 0 1 2 3 ……
2/3 2/3 2/3 2/3
Reading assignment
Read Chapters 5.1–5.4 in Applied Probability and Stochastic
Processes by Feldman and Valdez-Flores
Exercise problems
To be posted on LumiNUS