Math 450 Lect 05
Math 450 Lect 05
tQ t2 Q2 t3 Q3
P (t) = I + + + + ···
1! 2! 3!
constitute a family of stochastic matrices. P (t) = (pij (t)) will be seen to be the
transition probability matrix at time t for the Markov chain (Xt ) associated to
Q. The chain (Xt ) will be defined later not directly in terms of the transition
probabilities but from two discrete-time processes (the holding times and jump
chains) associated to Q, to be defined later. Only after that will we derive the
interpretation
pij (t) = Pi (Xt = j) = P (Xt = j|X0 = i).
1
In fact, we will prove later that a continuous-time Markov chain (Xt )t≥0 derived
from a Q-matrix satisfies:
2 A few examples
The information contained in a Q-matrix is conveniently encoded in a transition
diagram, where the label attached to the edge connecting state i to state j is
the entry qij . We disregard all self-loops.
Example 1. We begin by examining the process defined by the diagram of
figure 1.
λ
1 2
The Q-matrix associated to this diagram has entries −q11 = q12 = λ and
q21 = q22 = 0. To obtain the stochastic matrix P (t) we use Theorem 2.1.1,
which shows that P (t) satisfies the equation P 0 (t) = QP (t) with initial condi-
tion P (0) = I. It is immediate that the entry p11 (t) of P (t) must satisfy the
differential equation y 0 = −λy with the initial condition y(0) = 1. This gives
y(t) = e−λt , so that −λt
1 − e−λt
e
P (t) = ,
0 1
The key remark is that the time of transition from 1 to 2 has exponential
distribution with parameter λ. (See Lecture Notes 3, section 5.) We will recall
later some of the salient features of exponentially distributed random variables.
Example 2. The next example refers to the diagram of figure 2.
The Q-matrix for this example is
−µ λ1 ... λN
0 0 ... 0
Q=
.. .. .. ..
. . . .
0 0 ... 0
2
j
2
λj λ2
λΝ λ1
Ν 0 1
the equation
N
X
p0ij (t) = qik pkj (t)
k=0
The solution can be interpreted as follows: assuming that the process is initially
at state zero, the transition to a state j 6= 0 happens at an exponentially dis-
tributed random time with parameter µ = λ1 + · · · + λN . At that jump time,
the new state j is chosen with probability
λj
gj = .
λ1 + · · · + λN
Example 3. We study now the process defined by the diagram of figure 3.
The transition probabilities pij (t) can be obtained as in the previous examples.
λ1 λ2 λ3
1 2 3
3
It can be shown in this case that at each state i the process waits a random
time, exponentially distributed with parameter λi , then jumps to the next state
i + 1. The mean holding (waiting) time at state i is 1/λi . (See properties of
exponential distribution in Lecture Notes 3.) Denote by Sn the holding time
before the n-th transition (to state n) Note that the expected value of the sum
ζ = S1 + S2 + . . . is finite if
∞
X 1
< ∞.
λ
i=1 i
In this case, J must be finite with probability 1. (If a random variable assumes
the value ∞ with positive probability, its expected value is infinite. This is clear
since the weighted average of a set of numbers that includes ∞ with positive
weight is necessarily equal to ∞.) The random variable ζ is called the first
explosion time of the process. If the process has finite explosion time, it will
run through an infinite number of transitions in finite time. We will have more
to say about this phenomenon later.
We consider in more detail the special case of the last example having con-
stant λi = λ. The transition probabilities in this case can be calculated (see
example 2.1.4 in text) to be
(λt)j−i
pij (t) = e−λt .
(j − i)!
The infimum, or inf, of a set A of real numbers is the unique number a (not
necessarily in A) such that every element of A is greater than or equal to a (i.e.,
a is a lower bound for A) any no other lower bound for A is greater than a.
4
Thus Jn+1 is the least random time greater than Jn at which the process takes
a new value Xt 6= XJn . In the definition of Jn+1 the infimum is evaluated for
each sample path. A more explicit statement is that for each ω ∈ Ω, Jn+1 (ω)
is the infimum of the set of times t ≥ tn = Jn (ω) such that Xt (ω) is different
from Xtn (ω). It could happen that the process gets stuck at an absorbing state
and no further transitions occur. In this case Jn+1 (ω) = ∞. In this case we
define XJn = X∞ (the final value of Xt ). If all Jn are finite, the final value of
the process is not defined.
We also define the holding times Sn , n = 1, 2, . . . , as the random variables
(
Jn − Jn−1 if Jn−1 < ∞
Sn =
∞ otherwise.
The right-continuity condition implies that the holding times Sn are positive
for all n, that is, there cannot be two state transitions happening at the same
time. It is, nevertheless, possible in principle for a sequence of jump times to
accumulate at a finite time. In other words, the random variable
∞
X
ζ= Sn
n=1
may be finite. The random variable ζ is called the first explosion time. As we
saw in the birth process in the previous section, it is possible that the holding
times of a sequence of state transitions become shorter and shorter, so that the
chain undergoes an infinite number of transitions in a finite amount of time.
This is called an explosion. We will describe later simple conditions for the
process to be non-explosive.
The analysis of a continuous-time Markov chain (Xt )t≥0 can be approached
by studying the two associated processes: the holding times Sn and the jump
process Yn , n = 0, 1, 2, . . . . This is explained in the next section.
5
As an example, consider the process specified by the Q-matrix:
−2 1 0 1 0 0
0 0 0 0 0 0
0 1 −4 0 0 3
Q=
2 0
0 −4 2 0
0 3 1 0 −5 1
0 0 0 0 0 0
1 1
1 2 3
1 2 3 1 3
4 5 6
2 1
0 12 1
0 2 0 0
0 1 0 0 0 0
0 1 3
4 0 0 0 4
Π= 1 0 1
2 3 0 0 2 0
0 1 1
5 5 0 0 5
0 0 0 0 0 1
6
generator matrix Q, written Markov(λ, Q), as the (right-continuous) process
(Xt )t≥0 given by
Xt = Yn if Jn ≤ t < Jn+1 .
This definition can be modified to include explosive chains. This amounts to
adding to S an extra state, denoted ∞, which is attained after explosion, and
defining Xt = ∞ if t does not lie in any of the intervals [Jn , Jn+1 ).
Representing a continuous-time Markov chain as a hold-and-jump process is
particularly useful as it suggests a method of stochastic simulation. We pursue
this in the next section.
7
chamber i to j, while flow from j to i is controlled by gate (j, i). Each gate opens
independently of all others at random times for very brief moments, and when-
ever it does, anyone waiting to pass will immediately take the opportunity to do
so. Over a period [0, t], the gate (i, j) will open at times according to a Poisson
process with parameter qij . In other words, The number of times, Nij (t), that
the gate opens during [0, t] is a Poisson random variable with parameter qij t,
and these events are distributed over [0, t] uniformly. Now, someone moving in
this maze, presently waiting in chamber i, will move next to the chamber whose
gate from i opens first. The chain then corresponds to the sequence of chambers
the person visits and the waiting times in each of them.
We now describe an algorithm that implements the hold-and-jump chain.
The following assumes a finite state space S:
1. Initialize the process at t = 0 with initial state i drawn from the distribu-
tion λ;
2. Call the current state i; simulate the time of the next event, t0 , as an
Exp(qi ) random variable;
3. Set the new value of t as t ← t + t0 ;
4. Simulate the new state j: if qi = 0, set j = i and stop. If qi 6= 0, simulate
a discrete random variable with probability distribution given by the i-th
row of the Π-matrix, i.e., qij /qi , j 6= i;
5. If t is less than a pre-assigned maximum time Tmax , return to step 2.
The following program implements this algorithm in Matlab.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [t y]=ctmc(n,pi,Q)
%Obtain a sample path with n events for a
%continuous-times Markov chain with initial
%distribution pi and generator matrix Q.
%The output consists of two row vectors:
%the event times t and the vector of states y.
%Vectors t and y may be shorter than n if
%an absorbing state is found before event n.
%Uses samplefromp(pi,n).
t=[0];
y=[samplefromp(pi,1)]; %initial state
for k=1:n-1
i=y(k);
q=-Q(i,i);
if q==0
break
else
s=-log(rand)/(-Q(i,i)); %exponential holding time
8
t=[t t(k)+s];
p=Q(i,:);
p(i)=0;
p=p/sum(p);
y=[y samplefromp(p,1)];
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
As an example to illustrate the use of the program, consider the birth-and-
death chain given by the diagram of figure 5.
1 1 1 1 1
1
1 2 3 4 5 6 7
2 2 2 2 2
The first 50 events of a sample path of the chain of figure 5 are shown in
figure 6.
5
states
1
0 10 20 30 40 50 60 70 80
time
Figure 6: A sample path for the continuous-time Markov chain of figure 5. The
initial state is 1. The chains stopped at after 157 events, at the absorbing state
7.
9
Q(2,[1 2 3])=[2 -3 1];
Q(3,[2 3 4])=[2 -3 1];
Q(4,[3 4 5])=[2 -3 1];
Q(5,[4 5 6])=[2 -3 1];
Q(6,[5 6 7])=[2 -3 1];
pi=[1 0 0 0 0 0 0];
[t y]=ctmc(50,p,Q);
stairs(t,y)
grid
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
It is worth to mention the following modification of the algorithm given above
for simulating a continuous-time Markov chain. It is based on the property that
if we have k independent exponential random variables T1 , . . . , Tk of parameters
λ1 , . . . , λk , respectively, then T = mini {Ti : i = 1, . . . , k} is also an exponential
random variable of parameter λ1 +· · ·+λk . Although it may not be immediately
obvious, the following algorithm produces another version of exactly the same
process as the first algorithm:
1. Initialize the process at t = 0 with initial state i drawn from the distribu-
tion λ;
2. Call the current state i. For each potential next state l (k 6= i), simulate
a time tl with the exponential distribution of parameter qil . Let j be the
state for which tj is minimum among the tl ;
3. Set the new value of t as t ← t + tj ;
4. Let the new state be j;
5. If t is less than a pre-assigned maximum time Tmax , return to step 2.
Although equivalent, this algorithm is less efficient since it requires the sim-
ulation of more random variables.
10
1. The state set S is finite;
2. There exists a finite number M such that qi ≤ M for all i ∈ S;
3. The initial state, X0 = i, is recurrent for the jump chain having transition
probabilities matrix Π.
References
[Nor] J.R. Norris. Markov Chains, Cambridge Series in Statistical and Proba-
bilistic Mathematics, Cambridge U. Press, 1997.
[Wil] Darren J. Wilkinson. Stochastic Modelling for Systems Biology, Chap-
man & Hall/CRC, 2006.
11