A great number of problems involving Markov chains can be evaluated by a technique called first step analysis. The general idea of the method is to break down the possibilities resulting from the first step (first transition) in the Markov chain. Then use the law of total probability and Markov property to derive a set of relationship among the unknown variables. This technique is demonstrated in this previous post in several examples. In this post, the technique is further discussed. An alternative approach based on the fundamental matrix is also emphasized.
This previous post shows how to use first step analysis to solve two problems: to determine the probability of absorption from transient states and to determine the expected time spent in transient states. This post shows that first step analysis leads to an effective approach of using fundamental matrix for solving the same two problems. We illustrate using an example.
We start with Example 3 discussed in the previous post. It involves the following transition probability matrix.
The Markov chain represented by cycles through 5 states. Whenever the process reaches state 0 or state 4, it stays there and not move. These two states are called absorbing states. The other states (1, 2 and 3) are called transient states because the process stays in each of these states a finite amount of time. When the process starts at one of these states, it will eventually transition (be absorbed) into one of the absorbing states (0 or 4). Thus the matrix is called an absorbing Markov chain.
A natural question: how likely that the process is absorbed into state 0 versus state 4? Of course the answer to this question depends on the starting state.
Another question: if starting at state 1, 2 or 3, how many steps on average it will take for the process to be absorbed? In other words, what is the mean time to absorption? Of course, the answer will depend on the starting state.
Let the time it takes the process to be absorbed into 0 or 4. More specifically let be defined by . If the starting state is , let be the probability of the process being absorbed into state 0 and let be the expected time to absorption (into state 0 or state 4). The quantities and can also be defined as follows:
The quantities are the probabilities of absorption into state 0 and the quantities are the expected times to absorption (from each transient state). Applying the first step analysis produces the following two sets of equations.
We rearrange the equations by putting the variables or on one side and the constant terms on the other side.
The probabilities of absorption into state 0 are found by solving the system of equations (1a). The mean times to absorption are found by solving the system of equations (2a). It will be informative to write (1) and (2) in matrix notations.
Note that the same matrix appears on the left side of both (1b) and (2b). The quantities and can be found by multiplying both sides by the following inverse matrix.
Multiplying (1b) and (2b) by the inverse matrix produces the following.
The systems of equations (1a) and (2a) can certainly be solved by using other methods (e.g. Gaussian elimination). The inverse matrix approach is clean and can be implemented using software. More importantly, using the inverse matrix leads to a general description of the algorithm based on fundamental matrix.
How is the matrix in (1b) and (2b) obtained? Recall that the equations in (1a) and (2a) are obtained by rearranging the equations from the first step analysis. The first step analysis is of course based on the original transition probability matrix . The matrix in question is obtained from the transition probability matrix . The next two sections show how.
More about the Example
Before stating the algorithm, we continue to use the above example as illustration. The following is a rewrite of the transition probability matrix . Note that the transient states are grouped together.
The matrix is the 3 x 3 matrix of transition probabilities for the 3 transient states 1, 2 and 3. The matrix describes the transition probabilities between transient states. The matrix is a 3 x 2 matrix that shows the transition probabilities from transient to absorbing states. The matrix is a 2 x 3 matrix consisting of 0’s. The matrix is an identity matrix describing the absorbing states (in this case 2 x 2).
The key matrix is the matrix where is a 3 x 3 identity matrix.
The matrix , the inverse of , is called the fundamental matrix for the absorbing chain in question. As shown above, the fundamental matrix is used in finding the probabilities of absorption and the mean times to absorption.
Recall that an absorbing Markov chain has at least one absorbing state such that every non-absorbing state will eventually transition into an absorbing state (i.e. will eventually be absorbed). The non-absorbing states in such a chain are called transient states.
Consider an absorbing Markov chain with transition probability matrix . Suppose that the chain has states with transient states and absorbing states . Such labeling is for convenience. As the above example shows, the rearranging of the states is not necessary as long as one can keep the transient states apart from the absorbing states.
Write the matrix in the following form
where consists of where and consists of where and . In other words, the matrix contains the one-step transition probabilities between transient states and contains the one-step transition probabilities from transient states into absorbing states. The matrix is a matrix consisting of 0’s. The matrix is an identity matrix describing the absorbing states.
Consider the matrix where is the identity matrix. Then , the inverse of , is the fundamental matrix for the absorbing Markov chain.
Here is one important property of the matrix .
This leads to the following observation.
Here’s the property concerning probability of absorption.
To make the mathematical properties even more precise, consider . The variable is the random number of steps the process takes to reach an absorbing state. Define the following quantities.
where is any transient state () and is any absorbing state (). Here’s how to tie and to the above stated facts.
To further illustrate the technique, the next section has examples. It is critical that calculator or software be available for computing inverse matrix. Here is a useful online matrix calculator.
This is another calculation example to illustrate the technique. Use the following transition probability matrix to compute the quantities (the probabilities of being absorbed into states 0 and 4) and (the expected time spent in transient states 1,2 and 3 given the starting state is ). Of course is the random time to absorption defined by .
The following shows the matrices that are used in calculation.
Here’s the matrix calculation to obtain the desired quantities.
A fair coin is tossed repeatedly until the appearance of 4 consecutive heads. Determine the mean number of tosses required.
Consider the 5-state Markov chain with states 0, H, HH, HHH and HHHH. The state 0 means that the last toss is not a head. These 5 states are labeled 0, 1, 2, 3, 4 and 5, respectively.
Note that when a toss results in a tail, the process bounces back to the state 0. Otherwise, it advances to the next state (e.g. HH to HHH). The transient states are 0, 1, 2 and 3. State 4 is the absorbing state. The natural question is: on average how many tosses does it take to reach state 4 (to get 4 consecutive heads)? It is informative to obtain the matrix and to find its inverse.
The sum of the first row of is 30. It takes on average 30 tosses to get 4 consecutive heads if starting from scratch. After getting the first head, the process spends on average 28 tosses (the sum of the second row) before getting 4 consecutive heads. Even with three consecutive heads obtained, the chain still spends on average 16 tosses before reaching the state HHHH! On the surface, this may seem unbelievable. Remember that whenever a toss results in a tail, the process reverts back to 0 and the process essentially starts over again.
Example 3 (Occupancy Problem)
This example revisits the occupancy problem, which is discussed here. The occupancy problem is a classic problem in probability. The setting of the problem is that balls are randomly distributed into cells (or boxes or other containers) one at a time. After all the balls are distributed into the cells, we examine how many of the cells are occupied with balls. In this particular example, the number of balls is not fixed. Instead, balls are thrown into the cells one at a time until all cells are occupied. On average how many balls have to be thrown to achieve this?
More specifically, let (cells). On average, how many balls have to be thrown until all 6 cells are occupied? Let be the number of occupied cells after balls are thrown. The following is the transition probability matrix describing this Markov chain.
For a more detailed discussion on this matrix, see the previous post on the occupancy problem. The transient states here are 0, 1, 2, 3, 4 and 5. Extract the matrix with these 5 transient states. Derive the matrix . The following is the inverse of .
The sum of the first row (the row for state 0) is 14.7. If starting with all 6 cells empty, it will take on average the throwing of 14.7 balls to have all 6 cells occupied. If there is already one ball in the 6 cells, then it will take on average 13.7 balls to fill the 6 cells. The decrease in the number of throws is not linear. When there are already 4 occupied cells, it will take on average 9 throws to fill the cells. When there is only one empty cell, it will take on average 6 more throws to fill the cells.
Because the number of cells is 6, the problem can be interpreted as rolling a die. The question can be restated: in rolling a fair die, how many rolls does it take on average to have each side of the die appeared at least one?
There is yet another interpretation of the problem of throwing balls into cells until all cells are occupied. This is precisely the coupon collector problem. The 6 cells in the example would be like 6 different coupon types (e.g. promotional prizes that come with the purchase of a product). When such a product is purchased, a prize (a coupon) is given at random. How many units of the product do you need to buy in order to have collected each of the coupon types at least once? For a fuller discussion on the coupon collector problem, see this blog post in a companion blog.
Example 4 (Gambler’s Ruin)
Consider a small scaled gambler’s ruin problem. Say, and . That is, the gambler makes a series of one-unit bets against the house such that the probability of winning a bet is 0.48 and such that the gambler stops whenever his total capital is 0 units (the gambler is in ruin) or 8 units.
Let be the gambler’s capital (the number of units) after the th bet. The following is the transition probability matrix describing this Markov chain.
There are two absorbing states in this chain, state 0 and state 8 (ruin or winning all units). The transient states are 1, 2, 3, 4, 5, 6 and 7. As discussed in this post, is the matrix consisting of all transition probabilities from the transient states into the transient states. Then derive the matrix and compute its inverse.
The fundamental matrix gives a wealth of information about the prospect for the gambler in question. Suppose the gambler initially has 3 units in capital. The sum of the third row is 14.49, roughly 14.5. So on average the gambler makes 14.5 bets before reaching one of the two absorbing states (in ruin or owning all 8 units). With one bet = one period of time, the gambler spends on average 3.72 periods of time in state 3. Note that most of the time the gambler is in the lower capital states. The gambler that has initially 3 units only spends on average 0.6303 amount of time in state 7, an indication that the gambler does not have a great chance of winning all 8 units.
The matrix gives the probabilities of absorption.
The first column of gives the probabilities of ruin for the gambler. The smaller the initial capital, the greater the probability of ruin. With 3 units initially, the gambler has an almost 70% chance of ruin.
More about Fundamental Matrix
The fundamental matrix of an absorbing Markov chain is central to the technique described here. We now attempt to give an indication why the technique works.
Let be the transition probability transition matrix for an absorbing Markov chain. Suppose that is stated as follows
such that is the submatrix of that consists of the one-step transition probabilities between transient states and is the submatrix of that consists of the one-step transition probabilities from transient states into absorbing states. The fundamental matrix is , which is the inverse of the matrix where is the identity matrix of the same size as .
We sketch an answer to two questions. Why each entry in the fundamental matrix is the mean time the process spent in state given that the process starts in state ? Why the matrix gives the probabilities of absorption?
Note that the entries in , the th power of the matrix , approach zero as becomes large. This is because contains the one-step transition probabilities of the transient states (once in a transient state, the process has to leave the transient states at some point). We have the following equality.
To see the equality (3), fix transient states and with . We show the following:
Suppose the process starts at state . Define the indicator variables and for . At time , if the process is in state , let . Otherwise . Likewise, at time , if the process is in state , let . Otherwise . By definition,
are the times spent in state and in state , respectively. The 1 in the first random time accounts for the fact that the process is already in state initially. Because we are dealing with transient states, only a finite number of and can be 1’s. So these two random time variables are well defined. Each is a Bernoulli random variable with . Likewise each is a Bernoulli random variable with . The following gives (4) and (5).
Expressing equalities (4) and (5) in matrix form gives the equality (3). The following derivation shows that .
Thus the mean times spent in the transient states are obtained by taking the inverse of the matrix . Based on the derivation, the sum for a sufficiently large would give a good approximation of the waiting time matrix . Of course, computationally speaking, it is much easier to compute the inverse matrix of .
For the second question, it is instructive to examine the power of . By induction on the power , can be expressed as follows:
The entries in the matrix are the -step transition probabilities from a transient state to an absorbing state. For example, if the starting state is the transient state and is an absorbing state, then is an entry of . Starting at a transient state, the process will be absorbed at some point in time. So the matrix gives good approximation for probabilities of absorption when is large. Note that approaches as goes to infinity.
The type of Markov chains discussed here are called absorbing Markov chains, the subject of next post.
Dan Ma Markov chains
Daniel Ma Markov chains