Example 1.1. A frog hops about on 7 lily pads. The number next to each arrow of Figure 1 is the probability with which, at the next jump, the frog moves along that arrow to a neighbouring pad. When the probabilities of the arrows leaving a pad sum to less than 1, the frog stays where it is with the remaining probability, drawn as a loop.
Figure 1. The 7 lily pads of Example 1.1 and the probabilities of the jumps between them.
There are 7 states, the lily pads. The probabilities of the jumps form the matrix
The element p57=21 of P is the probability that, when starting in state 5, the next jump takes the frog to state 7. We would like to know where the frog goes, how long it takes to get there, and what happens in the long run. Write p11(n) for the probability that the frog, starting in state 1, is in state 1 after n jumps. Specifically: (a) Starting in state 1, what is the probability that the frog is still in state 1 after 3 jumps, after 5 jumps, after 1000 jumps? The answers are p11(3)=41,p11(5)=163, and about 51 after 1000 jumps, because limn→∞p11(n)=51. (b) Starting in state 4, what is the probability that the frog ever reaches state 7? The answer is 31. (c) Starting in state 4, how long on average does it take to reach either state 3 or state 7? The answer is 311. (d) Starting in state 2, what is the long-run proportion of time spent in state 3? The answer is 52.
Markov chain models and methods are useful in answering questions such as the following. How long does it take to shuffle a deck of cards? How likely is a queue to overflow its buffer? How long does it take for a knight making random moves on a chessboard to return to its initial square? The answer is 168 if it starts in a corner and 42 if it starts near the centre. What do the hyperlinks between web pages say about their relative popularity?
Definition (Probability space). A probability space is a triple (Ω,F,P). The sample spaceΩ is the set of all possible outcomes of a random process. The event spaceF is a set of events, where an event is a subset of Ω. The probabilityP is a function that assigns a number between 0 and 1 to every event in F.
Definition (Random variable). Let E be a measurable space. A random variable with values in E is a measurable function X:Ω→E.
Definition (Distribution). The probability distribution of a random variable X describes how probability is assigned to the values of X.
Example (The outcome of 10 jumps). A sequence of positions of the frog is an experiment. The set of all experiments is the sample space Ω,F is a set of subsets of Ω, and P is a probability. Take the experiment of exactly 11 positions, that is, 10 jumps,
ω=(1,2,3,2,3,4,3,4,2,1,2).
The random variable Xn returns the position after n jumps, Xn(ω)=ωn, so X0(ω)=1,X1(ω)=2 and X2(ω)=3. A random variable takes as input an element of Ω, an outcome and not an event, and returns a value.
Let I be a countable set, with elements denoted i,j,k,…. Each i∈I is called a state and I is called the state space. We work in a probability space (Ω,F,P). The object of study is a sequence of random variables X0,X1,… with values in I whose joint distribution is determined by simple rules.
A row vector λ=(λi:i∈I) is called a measure if λi≥0 for all i∈I. If moreover ∑iλi=1, it is a distribution, or probability measure. We start with an initial distributionλ over I, which is the initial condition of the chain. The special case in which the chain starts in state i with probability 1 is denoted
λ=δi=(0,…,0,1,0,…),
with the entry 1 in position i. We also have a transition matrixP=(pij:i,j∈I). It is a stochastic matrix, meaning that pij≥0 for all i,j∈I and ∑jpij=1 for all i∈I, that is, each row of P is a distribution over I.
Definition 1.2 (Markov chain). A sequence (Xn)n≥0 of random variables with values in I is a Markov chain with initial distribution λ and transition matrix P if, for all n≥0 and i0,…,in+1∈I, the following two conditions hold. (i)P(X0=i0)=λi0. (ii) Whenever P(X0=i0,…,Xn=in)>0,
For short, we say that (Xn)n≥0 is Markov(λ,P). Checking conditions (i) and (ii) is usually the most helpful way to determine whether or not a given random process (Xn)n≥0 is a Markov chain. It can also be helpful to have the alternative description provided by Theorem 1.3.
Theorem 1.3. A sequence (Xn)n≥0 of random variables with values in I is Markov(λ,P) if and only if, for all n≥0 and i0,…,in∈I,
and for n=0,(1.1) is condition (i). On the other hand, if (1.1) holds, summing it over all i1,…,in gives P(X0=i0)=λi0, that is, (i). Then summing (1.1) over in gives P(X0=i0,…,Xn−1=in−1)=λi0pi0i1⋯pin−2in−1. Hence
At each time we apply some new randomness to determine the next step, in a way that is a function only of the current state. We might take U1,U2,… as independent and identically distributed (i.i.d.) random variables with values in a set E, and a function F:I×E→I such that u↦F(j,u) is measurable for every j∈I. Take i∈I. Set X0=i and define recursively
Xn+1=F(Xn,Un+1),n≥0.
Then (Xn)n≥0 is Markov(δi,P), where pjk=P(F(j,U)=k) for all j,k∈I and U has the common distribution of the Un. Indeed, X0,…,Xn are functions of U1,…,Un, so Un+1 is independent of them, and on the event {Xn=j} we have Xn+1=F(j,Un+1). Hence both conditional probabilities in (ii) equal pjk.
Label the states 1,2,…. Use a computer to simulate U1,U2,… as i.i.d. random variables uniformly distributed on [0,1], written U[0,1]. Define F(i,U)=J by the rules
Figure 2. The rules above on the chain of Example 1.1. The row of the current state Xn splits [0,1) into one interval for each state j with pXnj>0, and the interval containing the mark Un+1 gives Xn+1. The slider sets X0 and the button draws new uniform variables.
for every state i with λi>0; here and below a term λiPi(⋅) with λi=0 is read as 0. For example, Pi(X1=j)=pij. Given the initial distribution λ, we treat it as a row vector. Then
Here δi is a special case of λ. Thus P(n)=(pij(n)), the n-step transition matrix, is simply Pn, the matrix P raised to the power n. Also, for all i,j∈I and n,m≥0, the (obvious) Chapman–Kolmogorov equations hold:
pij(n+m)=k∈I∑pik(n)pkj(m).
They are named for their independent formulation by Chapman (a Trinity College graduate, 1880–1970) and Kolmogorov (1903–1987).