# A Numerical Algorithm on the Computation of the Stationary Distribution of a Discrete Time Homogenous Finite Markov Chain

Authors: Di Zhao; Hongyi Li; Donglin Su
Journal: Mathematical Problems in Engineering
 (2012)

---

## Abstract

The transition matrix, which characterizes a discrete time homogeneous
Markov chain, is a stochastic matrix. A stochastic matrix is a special nonnegative matrix with each row summing up to 1. In this paper, we focus on the computation of the
stationary distribution of a transition matrix from the viewpoint of the Perron vector
of a nonnegative matrix, based on which an algorithm for the stationary distribution
is proposed. The algorithm can also be used to compute the Perron root and the
corresponding Perron vector of any nonnegative irreducible matrix. Furthermore, a
numerical example is given to demonstrate the validity of the algorithm.


---

## Body

## 1. Introduction and Preliminaries

Throughout this paper, the following notations and definitions are used. A matrixA=(aij)∈ℝm×n is called nonnegative (positive), if all aij≥0 (aij>0), denoted by A≥0 (A>0). Similarly, a vector x=(x1,…,xn)T is called nonnegative (positive) and denoted by x≥0 (x>0), if all xi≥0 (xi>0). Let B=(bij)∈ℝm×n, we denote A≥B (A>B), if A-B≥0 (>0), that is, aij≥bij (aij>bij) for all i=1,2,…,m,j=1,2,…,n.For a square matrixA∈ℝn×n with eigenvalues λ1,…,λn,ρ(A)=max{|λj|} is called the spectral radius of A. If A≥0 is irreducible, there exists a unique eigenvector x=(x1,…,xn)T>0 such that Ax=ρ(A)x and ∥x∥1=|x1|+⋯+|xn|=1. In this case, we say that ρ(A) is the Perron root of A and x is the Perron vector [1].We consider a discrete-time Markov chainX={X(n):n=0,1,…} with a finite state space 𝒮={i1,…,in}. Among ergodic processes, homogeneous Markov chains with finite state space are particularly interesting examples. Such processes satisfy the Markov property, which states that their future behavior, conditional to the past and present, depends only on the present. Precisely, for all t∈ℝ+, h>0, and for all sequences 0≤t1≤⋯≤tr=t,i1,…,ir∈𝒮 and ij∈𝒮,
(1.1)P(X(t+h)=ij∣X(t)=ir,X(tr-1)=ir-1,…,X(t1)=i1)=P(X(h)=ij∣X(0)=ir).The behavior of such a process is characterized by ann×n matrix M called the transition matrix [2].Its stationary distributionπ, which is also its asymptotic distribution, is a vector satisfying the following.
(1.2)πTM=πT,∑j=1n‍πj=1,
that is,
(1.3)πTM=πT,π>0,πTe=1,
where e is the column vector of all ones.It has been established that it is possible to represent all possible uses of a software system as a Markov chain [3–5]. This model is called a Markov chain usage model. In a usage model, states of use (such as state “Document Loaded” in a model representing use of a word processing system) are represented by states in the Markov chain. Transitions between states of use (such as moving from state “Document Loaded” to “No Document Loaded” when the user closes a document in a word processing system) are represented by state transitions between the appropriate states in the Markov chain. Transitions between states of use have associated probabilities which represent the probability of making each transition. A usage model may be created based on information taken from functional specifications, usage specifications, and test objectives.Considering the problem of software reliability, we represent a software systemSf with n states of use {s1,…,sn} by a homogeneous discrete Markov chain {X(n):n=0,1,…} (the corresponding transition matrix is M). We denote the initial state probability distribution π(0)=(π1(0),…,πn(0))T, where πi(0)=P(X(0)=si). Then (π(k))T=(π(k-1))TM, where π(k) stands for the state probability distribution at time k. Let μi (i=1,…,n) be the probability when the software fails at state si. The reliability of Sf at time k can be defined as R(k)=1-∑i=1n‍μiπi(k). After a long time running, the state distribution of system Sf will tend to the stationary distribution π=(π1,…,πn)T. Then, the terminating reliability R=1-∑i=1n‍μiπi, with which we can evaluate the quality of a software system. By decreasing the μi of state si with the largest probability πi in the stationary distribution π, we can also enhance the reliability of Sf efficiently with limited resources.A nonnegative matrixA=(aij)∈ℝn×n is called a row-stochastic matrix (or a stochastic matrix for short) if ∑j=1n‍aij=1 for all i=1,…,n, that is, Ae=e.From the well-known Perron-Frobenius theorem, it can be easily deduced that the Perron root of a stochastic matrixA equals 1.Obviously, the transition matrixM of a discrete-time homogeneous Markov chain is a stochastic matrix. From (1.3), we have MTπ=π. That is to say, the stationary distribution π is also an eigenvector of MT associated to 1. Since MT and M have the same eigenvalues, π is the Perron root of MT, that is, the solution to MTπ=π. As for the computational aspects of π, many approaches have been presented (e.g., see [6–10]) based on the Gaussian elimination, direct projection and so on. In this paper, from the viewpoint of the Perron root which has not been discussed, we propose an algorithm for the stationary distribution π considering that the computation of π is equivalent to the computation of the Perron vector of M, which not only can compute the stationary distribution, but also could be used to compute the Perron root and the corresponding Perron vector of any nonnegative irreducible matrix (noting that the stationary distribution is the Perron vector of the transition matrix, which is a special nonnegative matrix).This paper is organized as follows. In the next section, we propose some lemmas and preliminary results. In Section3, we prove the convergent theorem and give some facts. In Section 4, we propose an algorithm for the stationary distribution together with a demonstrating numerical example.


## 2. Some Lemmas

In this section, we present some lemmas which will be used in the proof of the main results. The following facts can be found in [1, 11, 12].Definition 2.1 (see [1]).
LetA∈ℝn×n be a nonnegative matrix. If Am>0 for some integer m≥1, one says that A is primitive.It is known that any primitive matrix must be irreducible [12]. We will use the following important facts which can be found in [1, 12].Theorem A (see [1]).
LetA=An×n≥0, then A is irreducible if and only if (I+A)n-1>0, where I is the unit matrix.Theorem B (Perron-Frobenius (see [1])).
LetA=An×n≥0 be irreducible. Then, (a)
ρ(A)>0,(b)
ρ(A) is an eigenvalue of A,(c)
There exists a vectorx>0 such that Ax=ρ(A)x,(d)
ρ(A) is a simple eigen value of A.This theorem guarantees the eigenspace ofρ(A) is one-dimensional. That is, Ay=ρ(A)y implies y=kx. And there exists an unique positive vector x>0 whose components sum to 1 such that Ax=ρ(A)x. This x is called the Perron vector [1].For the Perron root of nonnegative matrices, many algorithms and bounds estimations have been proposed (see in [13, 14]). In this paper, we will describe the Perron root by using the following Collatz-Wielandt functions [11, 12].Definition 2.2 (see [11]).
LetA=(aij)n×n be nonnegative, define
(2.1)fA(x)=min⁡(Ax)jxj,gA(x)=max⁡(Ax)jxj,
for any positive vector x=(x1,…,xn)T>0.f
A
(
x
) and gA(x) are both continuous at any x>0.Lemma 2.3.
LetA=An×n be nonnegative and irreducible. Then, for any x>0, fA(x) and gA(x) satisfy the following: (1)
Ax≥fA(x)x,Ax≤gA(x)x,andfA(x)≤∥A∥1,(2)
fA(tx)=fA(x),gA(tx)=gA(x)(t>0),(3)
Ax>tx gives fA(x)>t; Ax<tx gives gA(x)<t,(4)
IfB≥0 is irreducible and AB=BA, let y=Bx, then fA(y)≥fA(x) and gA(y)≤gA(x).Proof.
(1)–(3) are clearly true (see [10]). For (4), by Ax≥fA(x)x, it follows that Ay=B(Ax)≥BfA(x)x=fA(x)y. This gives fA(y)≥fA(x). Similarly, gA(y)≤gA(x).Lemma 2.4 (see [1]).
IfB≥0 is primitive (Bm>0 for some m≥1), then
(2.2)lim⁡k→∞[ρ(B)-1B]k=L>0,BL=ρ(B)L.


## 3. Main Results

In this section, we will present the main results.Theorem 3.1.
IfA=An×n≥0 is irreducible and B=Bn×n≥0 is primitive such that AB=BA. Let x(0)=(a1,…,an)T>0. Define for k=1,2,…,
(3.1)y(k)=Bx(k-1),x(k)=y(k)‖y(k)‖1.
Then, (a)
limk→∞x(k)=x>0, and Ax=ρ(A)x with ∥x∥1=1,(b)
limk→∞fA(x(k))=limk→∞gA(x(k))=ρ(A),(c)
fA(x(0))≤fA(x(1))≤⋯≤ρ(A)≤⋯≤gA(x(1))≤gA(x(0)).Proof.
By (3.1), we can write x(k)=Bkx(0)/bk (for some bk>0). This means for k=1,2,…(3.2)‖Bkx(0)bk‖1=‖x(k)‖1=1.
By Lemma2.4,
(3.3)lim⁡k→∞[Bρ(B)]k=L>0,BL=ρ(B)L.
Equations (3.2) and (3.3) imply that
(3.4)lim⁡k→∞bkρ(B)k=‖Lx(0)‖1,lim⁡k→∞x(k)=lim⁡k→∞Bkx(0)bk=Lx(0)‖Lx(0)‖1.
By putting x=Lx(0)/∥Lx(0)∥1, it is clear that x>0 (with ∥x∥1=1) and
(3.5)Bx=BLx(0)‖Lx(0)‖1=ρ(B)Lx(0)‖Lx(0)‖1=ρ(B)x.
Since AB=BA, we get B(Ax)=ρ(B)Ax. The Perron-Frobenius theorem (Theorem B) guarantees that ρ(B) is a simple eigenvalue of B. So, B(Ax)=ρ(B)Ax gives that Ax=λx(x>0), which implies that λ=ρ(A) and Ax=ρ(A)x. On the other hand, by Definition 2.2, Ax=ρ(A)x(x>0) gives fA(x)=ρ(A)=gA(x). By limk→∞x(k)=x(x>0), we conclude that
(3.6)lim⁡k→∞fA(x(k))=fA(x)=ρ(A),lim⁡k→∞gA(x(k))=gA(x)=ρ(A).
By Lemma 2.3 and (3.1), we have for k=1,2,…(3.7)fA(x(k-1))≤fA(x(k)),gA(x(k))≤gA(x(k-1)).
So, {fA(x(k))} and {gA(x(k))} are both monotonic convergent sequences. This proves (c), completing the proof.Remark 3.2.
From the proof, we knowABx=ρ(A)ρ(B)x (x>0), and ρ(AB)=ρ(A)ρ(B).
For ann×n irreducible matrix A≥0, since (bI+A)n-1>0(b>0), B=(bI+A)m are primitive for m=1,2,…. Clearly, BA=AB, we have the following.Corollary 3.3.
IfA=An×n≥0 is irreducible and let B=(bI+A)m (for fixed m≥1 and b>0). Let x(0)=(a1,…,an)T>0. For all k=1,2,…, define
(3.8)y(k)=Bx(k),x(k)=y(k)‖y(k)‖1.
Then, (a)
limk→∞x(k)=x>0,Ax=ρ(A)x,(∥x∥1=1),(b)
limk→∞fA(x(k))=limk→∞gA(x(k))=ρ(A),(c)
fA(x(0))≤fA(x(1))≤⋯≤ρ(A)≤⋯≤gA(x(1))≤gA(x(0)).For a positive matrixA>0, all the matrices B=Am(m=1,2,…) are primitive. The following is obvious.Corollary 3.4.
IfA=An×n>0 and B=Am (for m≥1). Let x(0)=(a1,…,an)T be a positive vector. Define
(3.9)y(k)=Bx(k),x(k)=y(k)‖y(k)‖1∀k=1,2,….
Then, (a)
limk→∞x(k)=x>0,Ax=ρ(A)x,(∥x∥1=1),(b)
limk→∞fA(x(k))=limk→∞gA(x(k))=ρ(A),(c)
fA(x(0))≤fA(x(1))≤⋯≤ρ(A)≤⋯≤gA(x(1))≤gA(x(0)).By (3.1), let λ(k)=(1/2)(fA(x(k))+gA(x(k))) for (k=1,2,…), one has the following.Corollary 3.5.
IfgA(x(k))-fA(x(k))<ε(ε>0), then |ρ(A)-λ(k)|<(1/2)ε.Proof.
From Theorem3.1, it follows that
(3.10)|ρ(A)-λ(k)|≤12|ρ(A)-fA(x(k))|+12|ρ(A)-gA(x(k))|=12(ρ(A)-fA(x(k)))+12(gA(x(k))-ρ(A))=12(gA(x(k))-fA(x(k)))<12ε.IfA≥0 is irreducible, it is obvious that B=bI+A(b>0) is primitive, and ρ(A)=ρ(B)-b. So, we have the following.Corollary 3.6.
IfA≥0 is irreducible, for any b>0, let B=bI+A. Using the sequences {fB(x(k))} and {gB(x(k))}. Then,
(3.11)lim⁡k→∞fB(x(k))=lim⁡k→∞gB(x(k))=ρ(B);lim⁡k→∞x(k)=x>0,(‖x‖1=1);ρ(A)=ρ(B)-b.


## 4. An Algorithm and a Numerical Example

In this section, we propose a numerical algorithm to compute the stationary distribution of a discrete time homogeneous finite Markov chain.Algorithm 4.1 (to compute the stationary distributionπ).
Step  1. Giving a transition matrix M of a discrete time homogeneous finite Markov chain, a calculation precision ε>0. Choosing parameters: a positive real number b>0 and an integer m. Setting the initial iterative vector π(0)=(1,1,…,1)T, B=(bI+MT)m, k=1.
Step  2. Computing π(k) from π(k-1):
(4.1)y(k)=Bπ(k-1),π(k)=y(k)∥y(k)∥1(∀k=1,2,…).
Step  3. Compute fMT(π(k)) and gMT(π(k)):
(4.2)fMT(π(k))=min⁡1≤i≤n(MTπ(k))iπi(k),gMT(π(k))=max⁡1≤i≤n(MTπ(k))iπi(k).
Step  4. If gMT(π(k))-fMT(π(k))<ε, go to Step 5. Otherwise setting k:=k+1, go back to Step 2.
Step  5. Let λ=(1/2)(fMT(π(k))+gMT(π(k))). Then λ is the approximation of the Perron root of MT, and the corresponding π(k) is the approximation of the stationary distribution of M.Remark 4.2.
From Theorem3.1, the convergence of Algorithm 4.1 is obvious.We next give a numerical example.Example 4.3.
For a given finite Markov Chain, with the corresponding transition matrix as the following:(4.3)M=[0.200.30.100.400.10.200.50.20.5000.100.400.30.20.20.10.20.30.1000.40.20.200.30.500],
finding its approximating stationary distribution with calculation precision ε=10-6.By choosing the initial iterative vectorx(0)=(1,1,1,1,1,1)T, parameters m=3,b=1, that is, B=(I+MT)3, and applying Algorithm 4.1, the approximating Perron root and Perron vector are obtained after 12 iterations:
(4.4)π(12)=(0.2115999,0.0758786,0.18776110,0.1956869,0.0958466,0.2332268)T,λ(12)=1.0000001.
The iteration results are listed in Table 1.Table 1
Iteration results of Example4.3 by Algorithm 4.1.
k
y
(
k
)
π
(
k
)
f
M
T
(
π
(
k
)
)
g
M
T
(
π
(
k
)
)
1
9.8480005
0.2051667
0.8266823
1.0792825
4.2060003
0.0876250
8.2880001
0.1726667
8.1380005
0.1695417
6.8360000
0.1424167
10.6840000
0.2225833
2
1.7046144
0.2130768
0.9024122
1.0330924
0.6064956
0.0758119
1.4543651
0.1817956
1.4877499
0.1859687
0.8997051
0.1124631
1.8470705
0.2308838
3
1.7026380
0.2128298
0.9654347
1.0107353
0.6010615
0.0751327
1.4877805
0.1859726
1.5420293
0.1927537
0.8042196
0.1005275
1.8622712
0.2327839
4
1.6968167
0.2121021
0.9906667
1.0030047
0.6042080
0.0755260
1.4985833
0.1873229
1.4985833
0.1949336
0.7754812
0.0969351
1.8654419
0.2331802
5
1.6940787
0.2117598
0.9979988
1.0010511
0.6060677
0.0757585
1.5014149
0.1876768
1.5642191
0.1955274
0.7683222
0.0960403
1.8658978
0.2332372
6
1.6931415
0.2116427
0.9997041
1.0003293
0.6067572
0.0758447
1.5020157
0.1877520
1.5653062
0.1956633
0.7668935
0.0958617
1.8658856
0.2332357
7
1.6928755
0.2116094
0.9999617
1.0000869
0.6069643
0.0758705
1.5021036
0.1877629
1.5654967
0.1956871
0.7667158
0.0958395
1.8658446
0.2332305
8
1.6928117
0.2116015
0.9999923
1.0000242
0.6070167
0.0758771
1.5021019
0.1877628
1.5655103
0.1956888
0.7667347
0.0958418
1.8658243
0.2332281
9
1.6927999
0.2116000
0.9999974
1.0000122
0.6070276
0.0758785
1.5020945
0.1877618
1.5655029
0.1956879
0.7667580
0.0958448
1.8658174
0.2332272
10
1.6927987
0.2115998
0.9999989
1.0000043
0.6070291
0.0758786
1.5020909
0.1877613
1.5654980
0.1956872
0.7667685
0.0958460
1.8658154
0.2332269
11
1.6927989
0.2115999
0.9999996
1.0000013
0.6070290
0.0758786
1.5020894
0.1877612
1.5654960
0.1956870
0.7667719
0.0958465
1.8658147
0.2332269
12
1.6927993
0.2115999
0.9999998
1.0000004
0.6070290
0.0758786
1.5020891
0.1877611
1.5654955
0.1956869
0.7667729
0.0958466
1.8658148
0.2332268



---

*Source: 167453-2012-07-16.xml*