Upcoming SlideShare
×

# Markov Chains

4,585 views
4,421 views

Published on

5 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
4,585
On SlideShare
0
From Embeds
0
Number of Embeds
28
Actions
Shares
0
395
0
Likes
5
Embeds 0
No embeds

No notes for slide

### Markov Chains

1. 1. Chapter 17 Markov Chains
2. 2. Description Sometimes we are interested in how a random variable changes over time. The study of how a random variable evolves over time includes stochastic processes. An explanation of stochastic processes – in particular, a type of stochastic process known as a Markov chain is included. We begin by defining the concept of a stochastic process.
3. 3. 5.1 What is a Stochastic Process? <ul><li>Suppose we observe some characteristic of a system at discrete points in time. </li></ul><ul><li>Let X t be the value of the system characteristic at time t . In most situations, X t is not known with certainty before time t and may be viewed as a random variable. </li></ul><ul><li>A discrete-time stochastic process is simply a description of the relation between the random variables X 0, X 1, X 2 ….. </li></ul><ul><li>Example: Observing the price of a share of Intel at the beginning of each day </li></ul><ul><li>Application areas: education, marketing, health services, finance, accounting, and production </li></ul>
4. 4. <ul><li>A continuous –time stochastic process is simply the stochastic process in which the state of the system can be viewed at any time, not just at discrete instants in time. </li></ul><ul><li>For example, the number of people in a supermarket t minutes after the store opens for business may be viewed as a continuous-time stochastic process. </li></ul>
5. 5. 5.2 What is a Markov Chain? <ul><li>One special type of discrete-time is called a Markov Chain. </li></ul><ul><li>Definition: A discrete-time stochastic process is a Markov chain if, for t = 0,1,2… and all states P ( X t+1 = i t+1 | X t = i t , X t-1 = i t-1 ,…, X 1 = i 1 , X 0 = i 0 ) = P ( X t+1 = i t+1 | X t = i t ) </li></ul><ul><li>Essentially this says that the probability distribution of the state at time t +1 depends on the state at time t ( i t ) and does not depend on the states the chain passed through on the way to i t at time t . </li></ul>
6. 6. <ul><li>In our study of Markov chains, we make further assumption that for all states i and j and all t , P ( X t+1 = j | X t = i ) is independent of t . </li></ul><ul><li>This assumption allows us to write P ( X t+1 = j | X t = i ) = p ij where p ij is the probability that given the system is in state i at time t , it will be in a state j at time t +1. </li></ul><ul><li>If the system moves from state i during one period to state j during the next period, we call that a transition from i to j has occurred. </li></ul>
7. 7. <ul><li>The p ij ’s are often referred to as the transition probabilities for the Markov chain. </li></ul><ul><li>This equation implies that the probability law relating the next period’s state to the current state does not change over time. </li></ul><ul><li>It is often called the Stationary Assumption and any Markov chain that satisfies it is called a stationary Markov chain . </li></ul><ul><li>We also must define q i to be the probability that the chain is in state i at the time 0; in other words, P ( X 0 = i ) = q i . </li></ul>
8. 8. <ul><li>We call the vector q = [ q 1 , q 2 ,…q s ] the initial probability distribution for the Markov chain. </li></ul><ul><li>In most applications, the transition probabilities are displayed as an s x s transition probability matrix P . The transition probability matrix P may be written as </li></ul>
9. 9. <ul><li>For each I </li></ul><ul><li>We also know that each entry in the P matrix must be nonnegative. </li></ul><ul><li>Hence, all entries in the transition probability matrix are nonnegative, and the entries in each row must sum to 1. </li></ul>
10. 10. The Gambler’s Ruin Problem <ul><li>At time 0, I have \$2. At times 1, 2, …, I play a game in which I bet \$1, with probabilities p, I win the game, and with probability 1 – p, I lose the game. My goal is to increase my capital to \$4, and as soon as I do, the game is over. The game is also over if my capital is reduced to 0. </li></ul><ul><ul><li>Let X t represent my capital position after the time t game (if any) is played </li></ul></ul><ul><ul><li>X 0 , X 1 , X 2 , …. May be viewed as a discrete-time stochastic process </li></ul></ul>
11. 11. The Gambler’s Ruin Problem <ul><li>\$0 \$1 \$2 \$3 \$4 </li></ul>
12. 12. 5.3 n -Step Transition Probabilities <ul><li>A question of interest when studying a Markov chain is: If a Markov chain is in a state i at time m , what is the probability that n periods later the Markov chain will be in state j ? </li></ul><ul><li>This probability will be independent of m , so we may write P ( X m+n = j | X m = i ) = P ( X n = j | X 0 = i ) = P ij ( n ) where P ij ( n ) is called the n -step probability of a transition from state i to state j . </li></ul><ul><li>For n > 1, P ij ( n ) = ij th element of P n </li></ul><ul><li>P ij (2) is the (i, j)th element of matrix P 2 = P 1 P 1 </li></ul><ul><li>P ij (n) is the (i, j)th element of matrix P n = P 1 P n-1 </li></ul>
13. 13. The Cola Example <ul><li>Suppose the entire cola industry produces only two colas. </li></ul><ul><li>Given that a person last purchased cola 1, there is a 90% chance that their next purchase will be cola 1. </li></ul><ul><li>Given that a person last purchased cola 2, there is an 80% chance that their next purchase will be cola 2. </li></ul><ul><ul><ul><li>If a person is currently a cola 2 purchaser, what is the probability that they will purchase cola 1 two purchases from now? </li></ul></ul></ul><ul><ul><ul><li>If a person is currently a cola 1 a purchaser, what is the probability that they will purchase cola 1 three purchases from now? </li></ul></ul></ul>
14. 14. The Cola Example <ul><li>We view each person’s purchases as a Markov chain with the state at any given time being the type of cola the person last purchased. </li></ul><ul><li>Hence, each person’s cola purchases may be represented by a two-state Markov chain, where </li></ul><ul><ul><li>State 1 = person has last purchased cola 1 </li></ul></ul><ul><ul><li>State 2 = person has last purchased cola 2 </li></ul></ul><ul><li>If we define X n to be the type of cola purchased by a person on her n th future cola purchase, then X 0 , X 1 , … may be described as the Markov chain with the following transition matrix: </li></ul>
15. 15. The Cola Example <ul><li>We can now answer questions 1 and 2. </li></ul><ul><li>We seek P ( X 2 = 1| X 0 = 2) = P 21 (2) = element 21 of P 2 : </li></ul>
16. 16. The Cola Example <ul><ul><li>Hence, P 21 (2) =.34. This means that the probability is .34 that two purchases in the future a cola 2 drinker will purchase cola 1. </li></ul></ul><ul><li>We seek P 11 (3) = element 11 of P 3 : </li></ul><ul><li>Therefore, P 11 (3) = .781 </li></ul>
17. 17. <ul><li>Many times we do not know the state of the Markov chain at time 0. Then we can determine the probability that the system is in state i at time n by using the reasoning. </li></ul><ul><li>Probability of being in state j at time n </li></ul><ul><li>where q =[q 1 , q 2 , … q 3 ]. </li></ul><ul><li>Hence, q n = q o p n = q n-1 p </li></ul><ul><li>Example, q 0 = (.4,.6) </li></ul><ul><ul><li>q 1 = (.4,.6) </li></ul></ul><ul><li>q 1 = (.48,.52) </li></ul>
18. 18. <ul><li>To illustrate the behavior of the n -step transition probabilities for large values of n , we have computed several of the n -step transition probabilities for the Cola example. </li></ul><ul><li>This means that for large n, no matter what the initial state, there is a .67 chance that a person will be a cola 1 purchaser. </li></ul>
19. 19. 5.4 Classification of States in a Markov Chain <ul><li>To understand the n -step transition in more detail, we need to study how mathematicians classify the states of a Markov chain. </li></ul><ul><li>The following transition matrix illustrates most of the following definitions. A graphical representation is shown in the book (State-Transition diagram) </li></ul>
20. 20. <ul><li>Definition: Given two states of i and j , a path from i to j is a sequence of transitions that begins in i and ends in j , such that each transition in the sequence has a positive probability of occurring. </li></ul><ul><li>Definition: A state j is reachable from state i if there is a path leading from i to j . </li></ul><ul><li>Definition: Two states i and j are said to communicate if j is reachable from i , and i is reachable from j . </li></ul><ul><li>Definition: A set of states S in a Markov chain is a closed set if no state outside of S is reachable from any state in S . </li></ul>
21. 21. <ul><li>Definition: A state i is an absorbing state if p ij =1. </li></ul><ul><li>Definition: A state i is a transient state if there exists a state j that is reachable from i , but the state i is not reachable from state j . </li></ul><ul><li>Definition: If a state is not transient, it is called a recurrent state. </li></ul><ul><li>Definition: A state i is periodic with period k > 1 if k is the smallest number such that all paths leading from state i back to state i have a length that is a multiple of k. If a recurrent state is not periodic, it is referred to as aperiodic . </li></ul><ul><li>If all states in a chain are recurrent, aperiodic, and communicate with each other, the chain is said to be ergodic . </li></ul><ul><li>The importance of these concepts will become clear after the next two sections. </li></ul>
22. 22. 5.5 Steady-State Probabilities and Mean First Passage Times <ul><li>Steady-state probabilities are used to describe the long-run behavior of a Markov chain. </li></ul><ul><li>Theorem 1: Let P be the transition matrix for an s -state ergodic chain. Then there exists a vector π = [ π 1 π 2 … π s ] such that </li></ul>
23. 23. <ul><li>Theorem 1 tells us that for any initial state i , </li></ul><ul><li>The vector π = [ π 1 π 2 … π s ] is often called the steady-state distribution , or equilibrium distribution , for the Markov chain. Hence, they are independent of the initial probability distribution defined over the states </li></ul>
24. 24. Transient Analysis & Intuitive Interpretation <ul><li>The behavior of a Markov chain before the steady state is reached is often call transient (or short-run) behavior . </li></ul><ul><li>An interpretation can be given to the steady-state probability equations. </li></ul><ul><li>This equation may be viewed as saying that in the steady-state, the “flow” of probability into each state must equal the flow of probability out of each state. </li></ul>
25. 25. Steady-State Probabilities <ul><li>The vector  = [  1 ,  2 , …. ,  s ] is often known as the steady-state distribution for the Markov chain </li></ul><ul><li>For large n and all i, </li></ul><ul><li>P ij (n+1)  P ij (n)   j </li></ul><ul><li>In matrix form  =  P </li></ul><ul><li>For any n and any i, </li></ul><ul><li>P i1 (n) + P i2 (n) + … + P is (n) = 1 </li></ul><ul><li>As n  , we have  1 +  2 + …. +  s = 1 </li></ul>
26. 26. An Intuitive Interpretation of Steady-State Probabilities <ul><li>Consider </li></ul><ul><li>Subtracting  j p jj from both sides of the above equation, we have </li></ul><ul><li>Probability that a particular transition enters state j = probability that a particular transition leaves state j </li></ul>
27. 27. Use of Steady-State Probabilities in Decision Making <ul><li>In the Cola Example, suppose that each customer makes one purchase of cola during any week. </li></ul><ul><li>Suppose there are 100 million cola customers. </li></ul><ul><li>One selling unit of cola costs the company \$1 to produce and is sold for \$2. </li></ul><ul><li>For \$500 million/year, an advertising firm guarantees to decrease from 10% to 5% the fraction of cola 1 customers who switch after a purchase. </li></ul><ul><li>Should the company that makes cola 1 hire the firm? </li></ul>
28. 28. <ul><li>At present, a fraction π 1 = ⅔ of all purchases are cola 1 purchases, since: </li></ul><ul><li>π 1 = .90 π 1 +.20 π 2 π 2 = .10 π 1 +.80 π 2 </li></ul><ul><li>and using the following equation by π 1 + π 2 = 1 </li></ul><ul><li>Each purchase of cola 1 earns the company a \$1 profit. We can calculate the annual profit as \$3,466,666,667 [2/3(100 million)(52 weeks)\$1]. </li></ul><ul><li>The advertising firm is offering to change the P matrix to </li></ul>
29. 29. <ul><li>For P 1, the steady-state equations become π 1 = .95 π 1 +.20 π 2 π 2 = .05 π 1 +.80 π 2 </li></ul><ul><li>Replacing the second equation by π 1 + π 2 = 1 and solving, we obtain π 1 =.8 and π 2 = .2. </li></ul><ul><li>Now the cola 1 company’s annual profit will be \$3,660,000,000 [.8(100 million)(52 weeks)\$1-(\$500 million)]. </li></ul><ul><li>Hence, the cola 1 company should hire the ad agency. </li></ul>
30. 30. Inventory Example <ul><li>A camera store stocks a particular model camera that can be ordered weekly. Let D 1 , D 2 , … represent the demand for this camera (the number of units that would be sold if the inventory is not depleted) during the first week, second week, …, respectively. It is assumed that the D i ’s are independent and identically distributed random variables having a Poisson distribution with a mean of 1. Let X 0 represent the number of cameras on hand at the outset, X 1 the number of cameras on hand at the end of week 1, X 2 the number of cameras on hand at the end of week 2, and so on. </li></ul><ul><ul><li>Assume that X 0 = 3. </li></ul></ul><ul><ul><li>On Saturday night the store places an order that is delivered in time for the next opening of the store on Monday. </li></ul></ul><ul><ul><li>The store using the following order policy: If there are no cameras in stock, 3 cameras are ordered. Otherwise, no order is placed. </li></ul></ul><ul><ul><li>Sales are lost when demand exceeds the inventory on hand </li></ul></ul>
31. 31. Inventory Example <ul><li>X t is the number of Cameras in stock at the end of week t (as defined earlier), where X t represents the state of the system at time t </li></ul><ul><li>Given that X t = i, X t+1 depends only on D t+1 and X t (Markovian property) </li></ul><ul><li>D t has a Poisson distribution with mean equal to one. This means that P(D t+1 = n) = e -1 1 n /n! for n = 0, 1, … </li></ul><ul><li>P(D t = 0 ) = e -1 = 0.368 </li></ul><ul><li>P(D t = 1 ) = e -1 = 0.368 </li></ul><ul><li>P(D t = 2 ) = (1/2)e -1 = 0.184 </li></ul><ul><li>P(D t  3 ) = 1 – P(D t  2) = 1 – (.368 + .368 + .184) = 0.08 </li></ul><ul><li>X t+1 = max(3-D t+1 , 0) if X t = 0 and X t+1 = max(X t – D t+1 , 0) if X t  1, for t = </li></ul><ul><li>0, 1, 2, …. </li></ul>
32. 32. Inventory Example: (One-Step) Transition Matrix <ul><li>P 03 = P(D t+1 = 0) = 0.368 </li></ul><ul><li>P 02 = P(D t+1 = 1) = 0.368 </li></ul><ul><li>P 01 = P(D t+1 = 2) = 0.184 </li></ul><ul><li>P 00 = P(D t+1  3) = 0.080 </li></ul>
33. 33. Inventory Example: Transition Diagram 0 1 2 3
34. 34. Inventory Example: (One-Step) Transition Matrix
35. 35. Transition Matrix: Two-Step <ul><li>P (2) = PP </li></ul>
36. 36. Transition Matrix: Four-Step <ul><li>P (4) = P (2) P (2) </li></ul>
37. 37. Transition Matrix: Eight-Step <ul><li>P (8) = P (4) P (4) </li></ul>
38. 38. Steady-State Probabilities <ul><li>The steady-state probabilities uniquely satisfy the following steady-state equations </li></ul><ul><li> 0 =  0 p 00 +  1 p 10 +  2 p 20 +  3 p 30 </li></ul><ul><li> 1 =  0 p 01 +  1 p 11 +  2 p 21 +  3 p 31 </li></ul><ul><li> 2 =  0 p 02 +  1 p 12 +  2 p 22 +  3 p 32 </li></ul><ul><li> 3 =  0 p 03 +  1 p 13 +  2 p 23 +  3 p 33 </li></ul><ul><li>1 =  0 +  1 +  2 +  3 </li></ul>
39. 39. Steady-State Probabilities: Inventory Example <ul><li> 0 = .080  0 + .632  1 + .264  2 + .080  3 </li></ul><ul><li> 1 = .184  0 + .368  1 + .368  2 + .184  3 </li></ul><ul><li> 2 = .368  0 + .368  2 + .368  3 </li></ul><ul><li> 3 = .368  0 + .368  3 </li></ul><ul><li>1 =  0 +  1 +  2 +  3 </li></ul><ul><li> 0 = .286,  1 = .285,  2 = .263,  3 = .166 </li></ul><ul><li>The numbers in each row of matrix P (8) match the corresponding steady-state probability </li></ul>
40. 40. Mean First Passage Times <ul><li>For an ergodic chain, let m ij = expected number of transitions before we first reach state j , given that we are currently in state i; m ij is called the mean first passage time from state i to state j . </li></ul><ul><li>In the example, we assume we are currently in state i . Then with probability p ij , it will take one transition to go from state i to state j . For k ≠ j , we next go with probability p ik to state k . In this case, it will take an average of 1 + m kj transitions to go from i and j . </li></ul>
41. 41. <ul><li>This reasoning implies </li></ul><ul><li>By solving the linear equations of the equation above, we find all the mean first passage times. It can be shown that </li></ul>
42. 42. <ul><li>For the cola example, π 1 =2/3 and π 2 = 1/3 </li></ul><ul><li>Hence, m 11 = 1.5 and m 22 = 3 </li></ul><ul><li>m 12 = 1 + p 11 m 12 = 1 + .9m 12 </li></ul><ul><li>m 21 = 1 + p 22 m 21 = 1 + .8m 21 </li></ul><ul><li>Solving these two equations yields, </li></ul><ul><li>m 12 = 10 and m 21 = 5 </li></ul>
43. 43. Solving for Steady-State Probabilities and Mean First Passage Times on the Computer <ul><li>Since we solve steady-state probabilities and mean first passage times by solving a system of linear equations, we may use LINDO to determine them. </li></ul><ul><li>Simply type in an objective function of 0, and type the equations you need to solve as your constraints. </li></ul>
44. 44. 5.6 Absorbing Chains <ul><li>Many interesting applications of Markov chains involve chains in which some of the states are absorbing and the rest are transient states. </li></ul><ul><li>This type of chain is called an absorbing chain . </li></ul><ul><li>To see why we are interested in absorbing chains we consider the following accounts receivable example. </li></ul>
45. 45. Accounts Receivable Example <ul><li>The accounts receivable situation of a firm is often modeled as an absorbing Markov chain. </li></ul><ul><li>Suppose a firm assumes that an account is uncollected if the account is more than three months overdue. </li></ul><ul><li>Then at the beginning of each month, each account may be classified into one of the following states: </li></ul><ul><ul><ul><li>State 1 New account </li></ul></ul></ul><ul><ul><ul><li>State 2 Payment on account is one month overdue </li></ul></ul></ul><ul><ul><ul><li>State 3 Payment on account is two months overdue </li></ul></ul></ul><ul><ul><ul><li>State 4 Payment on account is three months overdue </li></ul></ul></ul><ul><ul><ul><li>State 5 Account has been paid </li></ul></ul></ul><ul><ul><ul><li>State 6 Account is written off as bad debt </li></ul></ul></ul>
46. 46. <ul><li>Suppose that past data indicate that the following Markov chain describes how the status of an account changes from one month to the next month: </li></ul>New 1 month 2 months 3 months Paid Bad Debt New 1 month 2 months 3 months Paid Bad Debt
47. 47. <ul><li>To simplify our example, we assume that after three months, a debt is either collected or written off as a bad debt. </li></ul><ul><li>Once a debt is paid up or written off as a bad debt, the account if closed, and no further transitions occur. </li></ul><ul><li>Hence, Paid or Bad Debt are absorbing states. Since every account will eventually be paid or written off as a bad debt, New, 1 month, 2 months, and 3 months are transient states. </li></ul>
48. 48. <ul><li>A typical new account will be absorbed as either a collected debt or a bad debt. </li></ul><ul><li>What is the probability that a new account will eventually be collected? </li></ul><ul><li>To answer this questions we must write a transition matrix. We assume s – m transient states and m absorbing states. The transition matrix is written in the form of </li></ul>m columns s-m rows m rows s-m columns P =
49. 49. <ul><li>The transition matrix for this example is </li></ul><ul><li>Then s =6, m =2, and Q and R are as shown. </li></ul>New 1 month 2 months 3 months Paid Bad Debt New 1 month 2 months 3 months Paid Bad Debt Q R
50. 50. <ul><li>What is the probability that a new account will eventually be collected? (.964) </li></ul><ul><li>What is the probability that a one-month overdue account will eventually become a bad debt? (.06) </li></ul><ul><li>If the firm’s sales average \$100,000 per month, how much money per year will go uncollected? </li></ul><ul><ul><li>From answer 1, only 3.6% of all debts are uncollected. Since yearly accounts payable are \$1,200,000 on the average, (0.036)(1,200,000) = \$43,200 per year will be uncollected. </li></ul></ul>