- Learn
- Mathematics
- Statistics
- Probability Theory
- Markov Chains
Markov Chains
IntermediateLesson 9 of 9 in Probability Theory Course
What you will learn
- Describe a process that moves between states in steps, decide whether the Markov property fits it, and write the model as a transition matrix and a diagram.
- State the Markov property and choose the statesDefine a discrete-time Markov chain, explain what the Markov property says and does not say, and choose a state that carries all the information the future needs.
- Build and read transition matrices and diagramsWrite the one-step probabilities of a chain as a transition matrix and a transition diagram, check that they form a valid model, and compute the probability of a path.
- State the Markov property and choose the states
- Use powers of the transition matrix to find the probability of moving between states in several steps, and track the distribution of the chain over time.
- Find n-step transition probabilities with matrix powersDerive the n-step transition probabilities by conditioning on intermediate states, compute them as matrix powers, and use the Chapman–Kolmogorov equations.
- Track the distribution of the chain over timeCompute the distribution of the state at a later step from the initial distribution, tell conditional from unconditional probabilities, and find expected values of quantities that depend on the state.
- Find n-step transition probabilities with matrix powers
- Read the structure of a chain from its diagram: which states communicate, which are visited again and again, which are eventually left for good, how returns are spaced in time, and where an absorbing chain ends up.
- Find communicating classes and test irreducibilityDecide which states can reach which, split the states into communicating classes, and recognize closed classes, absorbing states and irreducible chains.
- Tell recurrent states from transient statesDefine recurrence and transience through the probability of returning, describe how often each kind of state is visited, and classify the states of finite chains from their classes.
- Find the period of a stateCompute the period of a state from its possible return times, recognize aperiodic chains, and explain why periodic chains behave differently in the long run.
- Compute absorption probabilities and expected steps by first-step analysisSet up and solve first-step equations for the probability of reaching a target and the expected number of steps it takes, including the gambler's ruin chain.
- Find communicating classes and test irreducibility
- Solve for the distributions that a chain leaves unchanged, know when such a distribution exists and is unique, and explain when and how fast the chain converges to it.
- Solve for a stationary distributionDefine a stationary distribution, set up and solve its balance equations, and check a proposed answer.
- Know when a stationary distribution is unique and what it meansState the existence and uniqueness results for finite chains, and interpret the stationary distribution through return times and long-run fractions of time.
- Decide whether a chain converges to its stationary distributionState the convergence theorem for finite chains, recognize the cases where convergence fails, and describe how fast the distribution approaches equilibrium.
- Solve for a stationary distribution
- Recognize reversible chains through detailed balance, find the stationary distribution of a random walk on a network, and compute and interpret PageRank as the stationary distribution of a modified random walk on the web.
- Check reversibility with detailed balanceDefine detailed balance and reversibility, prove that detailed balance gives a stationary distribution, and use it to solve chains such as birth–death chains.
- Analyze random walks on graphsWrite the transition probabilities of a random walk on an undirected network, find its stationary distribution from the degrees, and decide whether the walk is irreducible and aperiodic.
- Compute PageRank as a stationary distributionModel web browsing as a Markov chain, repair the problems of dangling pages and disconnected parts with teleportation, and compute PageRank by solving equations or by power iteration.
- Check reversibility with detailed balance
Markov Chains study guide
1Model random processes with Markov chains
A useful chain begins with a state that holds the information needed for the next move. Choosing too little information changes the model, even if its matrix looks valid. Connect the Markov property to practical state choices, then turn one-step rules into matrices, diagrams, and path probabilities. The order of the states and the meaning of each conditional probability will carry through every later calculation.
1.1 What the present state needs to remember
A machine can be working today and broken tomorrow. A Markov chain describes this kind of change as a sequence of random states. The key modeling question is what information each state must carry.
The present screens off the past
Write the sequence as . The state space lists all possible values of each state. It can be a finite set, such as Working and Broken, or a countable set, such as all integers for a walk that moves one unit at a time.
The Markov property says that once the present state is known, earlier states add no information about the next state:
This equality applies to histories with positive probability. It is a statement about conditional information. It allows tomorrow to depend strongly on today. For example, a broken printer can be much more likely to be broken tomorrow than a working printer is. Unconditional independence would remove that dependence too.
A chain is time-homogeneous when its one-step probabilities stay the same from one step to the next. We then write them as without a time index. Time-homogeneity and the Markov property answer different questions: whether the transition rule changes with time, and whether older history matters once the state is known.
Build a state that holds the needed history
Suppose tomorrow's rain probability depends on the last two days. It is 0.7 after Rain–Rain, 0.5 after Rain–Dry or Dry–Rain, and 0.2 after Dry–Dry. Today's weather alone loses useful information. If today is rainy, yesterday being rainy gives probability 0.7 for tomorrow, while yesterday being dry gives 0.5.
Use the pair as the state. Its four values are Rain–Rain, Rain–Dry, Dry–Rain, and Dry–Dry. From Rain–Rain, tomorrow gives Rain–Rain with probability 0.7 or Rain–Dry with probability 0.3. The new pair begins with the old pair's second entry. A direct move from Rain–Rain to Dry–Dry is impossible.
This construction works because the weather rule needs exactly those two days. Adding the relevant history makes the next pair depend only on the current pair. For a printer whose failure rate depends on whether it was repaired yesterday, the state likewise needs a repair-history flag as well as its current working condition.
Recognize other chains
A simple random walk has with probability and with probability . The current position determines the distribution of the next position. A player's token count or a token's square on a game board can serve the same role when the next move depends only on that recorded state.
Independent, identically distributed draws also form a Markov chain: their next-state distribution ignores even the present. For a real machine or weather record, justify why the chosen state contains the predictive information. Naming a process a chain cannot make missing information disappear.
Key Takeaways
- The Markov property removes the extra predictive value of the past once the present state is known.
- Time-homogeneity means that one-step probabilities stay constant over time.
- Enlarge a state when older information still changes the next-step distribution.
- Independent draws are a special case of a Markov chain.
1.2 From transition rules to matrices and paths
A transition matrix collects the one-step rules in one place. A diagram shows the same rules as arrows, making possible routes easier to see. Both representations require a fixed state order.
Read a row as a starting state
With states Working, Broken in that order, a working printer breaks with probability 0.1 and a broken printer is repaired with probability 0.6. The matrix is
The first row describes tomorrow given Working today. Its 0.9 includes staying Working. The second row describes tomorrow given Broken today. In general,
Every entry is nonnegative and every row sums to 1. Such a matrix is stochastic. Columns need not sum to 1: the printer's first column sums to 1.5, which is harmless because its two entries condition on different current states. When columns also sum to 1, the matrix is doubly stochastic.
Draw one node per state. Put an arrow from Working to Broken labeled 0.1 and an arrow back labeled 0.6. Add loops labeled 0.9 and 0.4. Leave out zero-probability arrows. The labels leaving each node must total 1.
Specify how the process begins
The initial distribution is a row vector . Its entry is the probability of starting in state . A known working printer has ; a printer working with probability 0.8 has . The matrix gives the same future rule for both, but their early behavior differs.
For a longer example, use states Sunny, Cloudy, Rainy in that order:
Here means rain tomorrow given sunshine today. It does not mean sunshine today given rain tomorrow. Reversing a conditional probability generally changes it.
Multiply along one specified path
Given sunshine today, the probability that the next three days are Sunny, Cloudy, Rainy is
Each factor starts where the previous move ended. The multiplication rule supplies conditional probabilities; the Markov property reduces each one to a one-step transition. For a path that also specifies a random starting state, include its starting probability:
If sunshine initially has probability 0.5, the same complete four-day path has probability 0.027. A conditional path probability leaves out that initial factor because the start is already known.
Check meaning as well as totals
Row totals catch missing loops and many copying errors. They cannot catch every reversed entry: a transposed doubly stochastic matrix still has row sums 1. Read a few entries aloud against the original transition rules. Some references use column distributions and the transposed matrix, so check the convention before multiplying.
To simulate a chain, sample the next state from the row of the current state, then repeat from the new row. For a working printer, choose Broken with probability 0.1 and Working with probability 0.9.
Key Takeaways
- Row gives the next-state probabilities conditional on current state .
- Entries are nonnegative and each row totals 1, including the chance of staying put.
- A diagram retains exactly the positive-probability arrows.
- The initial distribution supplies the starting probabilities.
- Multiply transition probabilities along a specified path; include the initial probability for a joint path event.
2Compute probabilities several steps ahead
One-step rules can answer questions many steps into the future, provided every possible route is included. Conditioning on intermediate states turns this task into matrix multiplication. Move from a known start to an uncertain initial distribution, then use the resulting state probabilities to calculate events at several times, expected outputs, and expected visit counts.
2.1 Several steps are sums over possible routes
A probability two steps ahead must account for every possible state in between. Matrix multiplication organizes that sum. Taking an ordinary power of one entry cannot do the same job.
Condition on the intermediate state
Let be the probability of being in state exactly steps after starting in . In a time-homogeneous chain it is independent of the calendar starting time. For two steps,
Each product is a route through one intermediate state. The routes are mutually exclusive, so add their probabilities. For the weather matrix with rows , , and , the chance of rain two days after sunshine is
The three terms correspond to tomorrow being sunny, cloudy, or rainy. Squaring 0.1 would apply a sunny-to-rainy move twice, even though the first move has already left the chain in Rainy. It describes no valid two-step path.
The whole two-step matrix is
Its rows still sum to 1: after two steps, the chain must be somewhere. Every power of a stochastic matrix is stochastic.
Split a longer journey at any time
The Chapman–Kolmogorov equations extend the same reasoning:
Look at the state after the first block of steps, then continue for the second block. In particular, the full collection of n-step probabilities is . The zero-step matrix is because no move leaves the state unchanged with probability 1.
For the printer matrix with rows and ,
One more step gives . Being broken at step 3 allows repairs and failures along the way. It does not require being broken at every earlier step.
Compute larger powers
For two states with move probabilities and , where ,
The first matrix has identical rows; the second carries the remaining effect of the starting state. For the printer, . Substituting 2 gives 0.13, agreeing with multiplication.
For larger matrices, repeated multiplication or software gives the powers. If is a diagonalization, then . A diagram can answer whether an entry is positive without computing it: exactly when a route of exactly n positive-probability arrows goes from i to j.
Key Takeaways
- An n-step probability is an entry of .
- Multiply along each route and add over intermediate states.
- Chapman–Kolmogorov splits a journey into two blocks of steps.
- Every matrix power has nonnegative entries and row sums 1.
- Positive entries of correspond to routes of exactly n arrows.
- A diagonalization can turn a matrix power into powers of eigenvalues.
2.2 Move a whole distribution forward
A known start selects one row of a matrix power. An uncertain start uses a weighted average of those rows. Keeping these two situations separate prevents many conditional-probability errors.
Update the probability vector
Write . To reach state j next, the chain can start the step in any state i. The law of total probability gives
Repeating the update gives . All distributions here are row vectors. With a column representation, transpose the matrix too: the corresponding update is . Using mixes conventions.
For the weather chain, the rows in Sunny, Cloudy, Rainy order are , , and . Suppose today is sunny or cloudy with equal probabilities. Then
For example, tomorrow's rain probability is . This differs from 0.1, the rain probability conditional on a known sunny start. One more update gives
Its sunny entry is .
Combine information from different times
If the start is known to be i, puts all mass on i and is row i of . With an uncertain start,
For a joint event at steps 2 and 5, first reach j at step 2, then take three more steps to k:
The gap is three steps, not five. If step 2's state is already known, an additional observation at step 1 changes nothing about the future transition from step 2. The Markov property gives whenever the conditioning event has positive probability.
Turn state probabilities into expected values
If a reward or output belongs to state j, use
For a count over several times, define an indicator for being in the state at each time. Linearity of expectation adds their probabilities even though the indicators are dependent:
A printer working at day 0 has broken-day probabilities 0.1, 0.13, and 0.139 on days 1–3. Its expected number of broken days over that period is 0.369. This is an average over possible paths, so it need not be a whole number.
A distribution describes uncertainty about the state. A nearly unchanged weather distribution can coexist with a path that keeps changing weather. An absorbing path, in contrast, can enter a state and remain there.
Key Takeaways
- With row distributions, .
- A known start selects one row; an uncertain start averages rows with the initial probabilities.
- For events at two times, use the transition matrix power for the time gap.
- Expected state rewards use probability-weighted values.
- Expected visit counts add the probabilities at each time, without requiring independence.
3Classify the states of a Markov chain
The arrangement of positive-probability arrows controls where a chain can go and whether it can return. Separate mutual accessibility from one-way escape, then examine the timing of returns. For chains with absorbing outcomes, first-step equations turn questions about eventual destinations and waiting times into linear systems with carefully chosen boundary values.
3.1 Which states can reach one another?
The arrows of a chain reveal where it can travel, where it can get trapped, and which starting states can ever meet. For these structural questions, only positive versus zero probabilities matter.
Accessibility is directional
State j is accessible from i if a positive-probability route leads from i to j in some number of steps. Write . A route can pass through other states; a direct arrow is unnecessary. We allow a zero-step route from a state to itself.
Two states communicate when each is accessible from the other. Write . Communication is reflexive, symmetric, and transitive: a route through an intermediate state can be joined to another route. Therefore it partitions the state space into disjoint communicating classes.
To find the classes, choose a state, list the states reachable from it, and keep those that can also get back. Repeat with an unassigned state. A singleton counts as a class even if it has no loop, because the zero-step convention makes it communicate with itself.
Identify closed classes
Consider
States 1 and 2 reach each other. Their rows have no positive entries in columns 3 or 4, so no route can leave their pair. They form a closed class, .
State 3 can move to 1 or 4 and can stay at 3. No arrow from any other state comes back to 3. Thus is its own communicating class, and it is not closed. In particular, the arrow from 3 to 4 does not put those states in the same class.
State 4 stays at 4 with probability 1. It is absorbing, and is a closed singleton class. Absorbing states are special closed classes; a larger closed class can keep moving internally forever.
| Class | Can leave the class? | Internal movement |
|---|---|---|
| 1 and 2 | No | Both directions are possible |
| 3 | Yes | Can stay or exit |
| 4 | No | Remains at 4 |
Decide whether the chain is irreducible
A chain is irreducible when it has one communicating class containing all its states. Every state can then reach every other, using as many steps as needed. The four-state chain is reducible because its three classes cannot all reach one another.
Both the printer and weather examples are irreducible. Their matrices have every entry positive, which is more than irreducibility requires. A directed cycle is also irreducible even though most one-step transitions have probability zero.
For an irreducibility test, changing a positive arrow's probability without removing it leaves accessibility unchanged, as long as the matrix remains stochastic. Conversely, removing even a very small arrow can split a class if it was the only return route. Follow the directions carefully: a chain that can leave a region but cannot reenter it has a one-way structural boundary.
Key Takeaways
- Accessibility needs a route in one direction; communication needs routes in both.
- Communicating classes partition the state space.
- A closed class has no outgoing arrow to a state outside it.
- An absorbing state is a closed singleton with a probability-1 loop.
- Irreducibility means one communicating class, not direct arrows between every pair.
3.2 Returns, escape, and recurrence
A chain can stay near a state for a long time yet eventually leave it forever. Recurrence concerns whether a return is certain, not whether the state looks common during a short simulation.
Start at the state being tested
Let be the probability of ever returning to i at a positive time, given . The state is recurrent if and transient if . The starting visit at time 0 is not a return.
At each return, the Markov property starts the same return experiment again. For a transient state, the number K of returns has probabilities
Thus . Counting the initial visit as well gives an expected total of visits. For a recurrent state, returns repeat infinitely often with probability 1.
Another test adds the probabilities of being back at every positive time:
This sum is the expected number of returns, by indicator variables and linearity of expectation. It is infinite exactly for recurrent states.
Use closed classes for a finite chain
Recurrence is a class property: communicating states are either all recurrent or all transient. In a finite chain, a communicating class is recurrent exactly when it is closed. Inside a finite closed class there are only finitely many states among which to keep moving. An exit from a nonclosed class creates a genuine chance of leaving that class for good.
For the matrix with rows , , , and , the classes 1–2 and 4 are closed, so all their states are recurrent. State 3 is transient. Once it exits to 1 or 4, it cannot return.
Starting at 3, a return occurs only if the very next step stays at 3. Hence and
A return at time 1 counts even though the chain never visibly moved away. The expected total number of visits, including time 0, is .
Every finite chain has at least one closed class and therefore a recurrent class. Every state of a finite irreducible chain is recurrent. A large self-loop by itself is insufficient: a state with a 0.99 chance of staying and a 0.01 chance of entering an inescapable region is still transient.
Infinite spaces change the result
For the simple walk on all integers with up-probability , the whole space is one closed communicating class. The walk is recurrent when and transient when . A persistent drift can carry it away despite the absence of an exit from the state space.
The symmetric walk on the integers returns with probability 1 but has infinite expected return time. This is null recurrence. A recurrent state with finite mean return time is positive recurrent; finite recurrent classes have this stronger property. For symmetric nearest-neighbor walks, Pólya's theorem gives recurrence in one and two dimensions and transience in three or more dimensions.
Key Takeaways
- Recurrence means certain eventual return from the state itself.
- A transient state has finitely many visits with probability 1.
- For a transient state, expected returns exclude time 0 and equal .
- In finite chains, closed communicating classes are exactly the recurrent classes.
- Closedness alone is insufficient for recurrence on an infinite space.
- Null recurrence means certain return with infinite mean return time.
3.3 Find the rhythm of possible returns
Some chains can return only on even steps, or only on multiples of three. The period describes this timing restriction. It depends on possible return lengths, not on the probabilities assigned to them.
Take the greatest common divisor
For a state with possible positive-time returns, its period is
The state is aperiodic when this gcd is 1 and periodic when it is greater than 1. All states in a communicating class have the same period. An irreducible chain therefore has a single shared period.
In the deterministic cycle , state 1 can return after 3, 6, 9, and so on. The gcd is 3. The same restriction holds at states 2 and 3, even though their routes begin at different positions.
A loop is sufficient, not necessary
A positive self-loop gives a one-step return, so its state's period is 1. In an irreducible chain, one such loop makes every state aperiodic because the period is shared across the class.
Now modify the three-state cycle: from 2, go to 1 or 3 with probability one half each; from 1 go to 2, and from 3 go to 1. State 1 can return in two steps through or three through . Since , this chain is aperiodic with no loops at all.
The shortest return here takes two steps, but the period is 1. Aperiodicity also does not require a one-step return. The gcd combines the timing information from all return routes.
Understand the flip chain
For
a return takes an even number of steps. The period is 2, and
Started at state 1, the probability of being at state 1 alternates between 1 and 0. It cannot approach a single limit. A walk on a connected bipartite undirected graph has the same parity problem: every move switches sides, so a return must use an even number of edges.
Connect period to matrix powers
For a finite irreducible chain, aperiodicity is equivalent to some power of Q having every entry strictly positive. Such a chain is often called regular. The term “ergodic” varies between books: some use it for irreducibility and others require aperiodicity too. Check the definition attached to the term.
A finite irreducible periodic chain has no limiting matrix . This does not prevent a stationary distribution from existing. In the flip chain, starting with equal probability on the two states keeps that distribution unchanged at every step. What fails is convergence from every initial distribution, particularly from a fixed starting state. Period is the condition that separates these two long-run claims.
Key Takeaways
- The period is the gcd of possible positive return times.
- Period is shared within a communicating class.
- A self-loop ensures period 1, but loops are not necessary.
- The shortest return time can differ from the period.
- For a finite irreducible chain, aperiodicity is equivalent to a strictly positive matrix power.
- A periodic chain can have a stationary distribution while its matrix powers fail to converge.
3.4 Solve absorption problems from the first move
First-step analysis turns a future event or waiting time into equations for the current state. The unknown after one move is the same kind of unknown, evaluated at the new state.
Fix boundary values before solving
Let be the probability of ever reaching a target set A from i. Put in A and at states from which A cannot be reached. At every remaining state,
For the four-state chain with closed classes 1–2 and 4, targeting state 4 gives and . At state 3, the row gives , so . The probability of entering class 1–2 is the remaining . Without the unreachable-state boundary, equations inside class 1–2 would only say the two unknowns are equal.
Work through gambler's ruin
A player gains one token with probability 0.4 and loses one with probability 0.6, stopping at 0 or 3. For the probability of reaching 3, the boundaries are and . The unknowns satisfy
Substitute the second into the first: . Hence , giving and .
For general boundaries 0 and N and , write . The upper-boundary probability is
In the example, and .
Count the steps themselves
For the expected time to a target reached with probability 1 in a finite chain, put at the target and write
outside it. The 1 counts the move just taken. For the same game, the target is either boundary, so
Then , giving and rounds. In the fair game the general expected duration is . If there is a positive chance of never reaching the target, the unconditional expected hitting time is infinite.
Collect the equations in a matrix
A finite absorbing chain has absorbing states reachable from every state. It is absorbed with probability 1. Order its transient states first. Let T contain transitions among transient states and R transitions from transient to absorbing states. The fundamental matrix is
Entry counts expected visits to transient j from i, including time 0. Row sums give expected steps to absorption; gives absorption probabilities. For the game,
Key Takeaways
- Hitting probabilities have boundary value 1 at the target and 0 where the target is unreachable.
- Expected-time equations add 1 for the first move and have value 0 at the target.
- In a finite absorbing chain, absorption occurs with probability 1.
- The fundamental matrix counts transient visits, including the starting visit.
- Row sums of the fundamental matrix give mean absorption times; multiplying by R gives absorption probabilities.
- A positive chance of never hitting the target makes its unconditional expected hitting time infinite.
4Find stationary distributions and describe long-run behavior
A probability distribution can remain unchanged while individual paths continue moving. Balance equations find these stationary distributions; the communicating classes tell you whether the answer is unique. Relate stationary mass to visit frequencies and return times, then check the extra conditions that make the distribution at a distant time approach the same limit from every start.
4.1 Find a distribution that one step leaves unchanged
A stationary distribution gives the same state probabilities before and after a transition. It describes a balance of probability across the states, even while individual paths move.
Set up the balance equations
A probability row vector is stationary when
For each state j, the balance equation is . The right side adds the incoming probability from all current states. Stationary distributions are also called invariant or equilibrium distributions.
If , then at every time. This claim concerns the distribution. It allows a path to move from state to state and allows neighboring times to be dependent.
The balance equations are linearly dependent. Because each row of Q sums to 1, adding all balance equations gives the same identity on both sides. Replace one equation with normalization, solve the remaining system, and check the result in the full equation . A reducible chain can leave free parameters; keep only nonnegative normalized solutions.
Solve the printer example
The printer has rows and in Working, Broken order. Balance for Working gives
so and . Normalization gives , hence
The second component checks as . In general, for two states with and and ,
The entry for state 1 has b in its numerator: faster movement back from state 2 increases the stationary share at state 1.
Extend the calculation to three states
For the weather chain, use the Sunny and Cloudy equations plus normalization:
Solving gives , approximately . Check the first component before rounding: . Dividing by 61 verifies Sunny's balance.
Use the right eigenvector convention
In linear algebra, is a left eigenvector of Q for eigenvalue 1, normalized as a probability vector. Equivalently, its transpose is an eigenvector of . Every stochastic matrix has eigenvalue 1, since multiplying Q by the all-ones column leaves it unchanged; every eigenvalue has absolute value at most 1.
Solving uses the wrong side for these row-stochastic matrices. The all-ones column solves that equation but usually cannot give the stationary shares by simple normalization. A useful valid shortcut is that a doubly stochastic matrix has a uniform stationary distribution. Detailed balance, when it applies, supplies another shortcut. Always finish by checking nonnegativity, a total of 1, and invariance under the actual matrix.
Key Takeaways
- Stationarity requires invariance, nonnegativity, and normalization.
- A stationary start keeps the same distribution at every time.
- Replace one dependent balance equation with normalization.
- The stationary row vector is a left eigenvector for eigenvalue 1.
- A doubly stochastic matrix admits the uniform stationary distribution.
4.2 Interpret stationary probabilities over a long run
Finite chains always have a stationary distribution, but the chain's class structure determines whether it is unique. Within an irreducible finite chain, its entries also describe visit frequencies and return times.
Existence and uniqueness
Every finite chain has at least one stationary distribution. A finite irreducible chain has exactly one, with all entries strictly positive. More generally, a finite chain has a unique stationary distribution exactly when it has one closed communicating class. Transient states receive stationary probability zero.
With several closed classes, each supports its own stationary distribution. Mixing these class distributions gives more stationary distributions. For the four-state chain, class 1–2 has stationary shares , while state 4 is absorbing. Every vector
is stationary. The parameter chooses how much probability to place in each closed class. No transition transfers that mass between the two classes.
Read entries as fractions of time
In a finite irreducible chain, the fraction of steps spent at j converges with probability 1 to , from any start. Aperiodicity is unnecessary for this time-average result. The flip chain alternates between two states, spending half its time at each, even though its distribution from a known start oscillates.
For the weather chain, the long-run sunny fraction is .
If a reward is attached to state j, the path's average reward converges to . A printer producing 700 pages on working days and zero on broken days has long-run output pages per day.
Return times use the reciprocal
The first return time to i is , starting from i. For a finite irreducible chain,
This includes a return at the very next step when the chain stays at i. It measures the time between successive visits, not the waiting time from an arbitrary other state.
For the printer, , so the mean return time to Broken is 7 days. Check directly: with probability 0.4 it is broken tomorrow, a return time of 1. Otherwise it is repaired after one day and waits a geometric number of days, mean 10, until it breaks again. Thus
A sunny day has mean return time days in the weather model.
Keep three long-run claims separate
Existence of a stationary distribution, time-average convergence, and convergence of the state distribution are different claims. The finite flip chain has a unique stationary distribution and stable visit fractions, yet no limiting distribution from a fixed start.
Infinite chains need further care. The symmetric walk on all integers is recurrent but has no stationary probability distribution. A candidate would need equal weights on all integers, which cannot be normalized to total 1. Its mean return time is infinite, consistent with null recurrence and the absence of a positive stationary mass at a state.
Key Takeaways
- Every finite chain admits a stationary distribution.
- Exactly one closed communicating class gives uniqueness in a finite chain.
- Stationary distributions give zero mass to transient states.
- In finite irreducible chains, visit fractions converge even when the chain is periodic.
- The mean return time to i from i is .
- Infinite recurrent chains need not have a stationary probability distribution.
4.3 When the distribution forgets the starting state
Stationarity describes an unchanged probability vector. Convergence asks whether other starting distributions approach that vector. The key finite-chain conditions are irreducibility and aperiodicity.
Apply the convergence theorem
For a finite irreducible aperiodic chain with stationary distribution ,
for every initial distribution. Equivalently, every row of approaches the same vector. The matrix eventually loses the effect of a particular starting state.
The printer is irreducible and has loops, so it satisfies the theorem. Starting Working,
The broken probabilities at steps 1, 2, and 3 are 0.1, 0.13, and 0.139. At step 5 the value is about 0.14251, and at step 10 it is about 0.142856, approaching . The error is exactly for this start.
For the weather chain, a Rainy start gives approximately at day 5. By day 10, all rows are within 0.0001 of . Rounded entries can total slightly more or less than 1; compute with the unrounded values.
Recognize what can fail
The flip matrix alternates between itself and the identity. It has a stationary vector , which remains unchanged when used as the start. From a known state, however, its distribution alternates forever. Irreducibility alone therefore cannot ensure convergence.
Reducibility can preserve information about where the chain began. In the four-state chain, starting in class 1–2 gives limit ; starting at 4 gives . From 3, entry probabilities into those classes are and , so the limit is
This chain's matrix powers converge, but their rows differ. Reducibility does not always produce different limits: if all states eventually enter one absorbing state, every start has the same limiting point mass.
Describe the speed
For a diagonalizable finite irreducible aperiodic Q, write deviations from stationarity in terms of its eigenvalues. The largest absolute eigenvalue other than 1 controls the slowest possible decaying component, roughly . A particular initial distribution may have no component in that direction and converge faster.
The printer's other eigenvalue is 0.3. The weather matrix's other eigenvalues are and . Their magnitudes describe how quickly starting-state information fades.
Remove a timing obstruction
The lazy version uses : stay with probability one half and otherwise take an ordinary step. It preserves stationarity since and gives every state a loop. For a finite irreducible chain this ensures convergence. It does not join separate communicating classes.
Convergence concerns probabilities across possible paths. A path in an irreducible chain with several states keeps moving; it need not settle at the state with the largest stationary share.
Key Takeaways
- Finite irreducibility and aperiodicity ensure convergence from every start.
- A periodic chain can keep a stationary start unchanged while other starts oscillate.
- Multiple closed classes can produce different limits for different starts.
- For diagonalizable chains, nonunit eigenvalues describe decaying deviations.
- Laziness preserves stationarity and removes periodicity without repairing reducibility.
5Use reversibility, random walks on graphs and PageRank
Networks give concrete ways to understand stationary probability flow. Detailed balance compares opposite directions along each connection, providing a shortcut for reversible chains and undirected walks. Directed web links need a different construction: repair missing outgoing transitions, add teleportation, and use stationary probabilities to rank pages through equations or repeated updates.
5.1 Balance each pair of opposite flows
Stationarity balances total probability at each state. Reversibility asks for a stronger balance: the stationary traffic along each arrow matches the traffic in the reverse direction.
Detailed balance proves stationarity
A distribution satisfies detailed balance when
for every pair. The quantity on the left is the probability of a step from i to j in a stationary chain. Equality means no net flow between that pair. A chain admitting such a distribution is reversible.
Sum these equations over i for a fixed j:
The final sum is row j of Q, so it is 1. The result is precisely j's stationary equation. For a reversible chain started in its stationary distribution, any finite path and its reversal have the same probability. Multiplying the pairwise equalities along the path explains that symmetry.
Stationarity can allow circulation
On a three-state circle, move clockwise with probability and counterclockwise with probability . Each column as well as each row sums to 1, so the uniform vector is stationary. Yet the stationary clockwise flow along one edge is and the reverse flow is . Probability circulates around the circle even though each state's total share stays constant.
Thus failure of detailed balance for a candidate does not reject stationarity. Test for that question. For a finite irreducible chain, a one-way positive arrow is enough to rule out reversibility: stationary masses are positive, so its flow cannot equal a zero reverse flow.
Kolmogorov's cycle criterion gives a complete reversibility test for finite irreducible chains. Every cycle's product of forward transition probabilities must equal its reversed product. In the circle, differs from . One failed cycle rules out reversibility; one successful cycle alone is insufficient in a graph with other independent cycles.
Use neighboring-state ratios
A birth–death chain on moves only up one state, down one state, or stays. A finite irreducible chain of this form is reversible. Balance between neighbors gives
For
we obtain and . The weights are 1, 2, 1, so normalization gives . Self-pairs satisfy detailed balance automatically, and nonneighbor pairs have zero flow in both directions.
Every two-state chain with a stationary distribution satisfies detailed balance because there is only one pair's flow to match. For the printer, . For a larger chain, the extra routes can carry a circulation, which is why global balance alone is weaker.
Key Takeaways
- Detailed balance equates stationary flows in each pair of opposite directions.
- Summing detailed balance proves stationarity.
- Stationarity can hold without reversibility.
- In a finite irreducible chain, reversibility is equivalent to equality of forward and reverse products on every cycle.
- Birth–death chains can be solved through adjacent-state ratios and normalization.
5.2 Read stationary weights from a network
A random walk on an undirected graph chooses a neighbor at each step. Nodes with more incident edges receive a larger stationary share, even though each individual outgoing edge is chosen less often there.
Normalize degrees
For a finite connected graph without loops and with at least one edge, let be the degree of vertex i and E the number of edges. The simple walk uses for neighbors and zero otherwise. Its stationary distribution is
Each edge has two ends, so the degrees sum to twice the edge count. Detailed balance gives the reason for the formula. Along any edge,
The stationary traffic in either direction is the same.
For edges A–B, A–C, B–C, and C–D, the degrees are 2, 2, 3, 1, totaling 8. Thus
C has the largest stationary share; D has the smallest. The mean return time to D is 8 steps. Dividing each degree by four vertices would produce entries totaling 2, not a probability distribution.
Check connectivity and timing separately
The walk is irreducible exactly when the graph is connected. On a connected loop-free graph, walking along an edge and back always gives a two-step return. Its period must therefore divide 2.
A bipartite graph splits into two groups with every edge crossing between groups. Every return has even length, so its period is 2. A square is an example. A nonbipartite connected graph has an odd cycle; odd and even return lengths together give period 1. The A–B–C triangle in the example ensures convergence to the degree distribution.
The lazy walk stays put with probability one half and otherwise makes a simple-walk move. It keeps the same stationary distribution but adds loops. On a finite connected graph, it converges even if the original graph was bipartite. On a disconnected graph, staying put cannot create routes between components.
Extend degrees to weights
Assign symmetric weights to edges, with zero for absent edges. Loops can be included. Define and use
In this convention a loop contributes once to the row weight. For example, a two-vertex weighted graph with edge weight 2 and loop weight 1 at each vertex has row weights 3 and 3. Each row stays with probability and crosses with probability ; the stationary vector is uniform.
Conversely, every finite irreducible reversible chain has a weighted-graph representation. Set . Detailed balance makes the weights symmetric and , so dividing by the row weight recovers Q.
Uniform stationarity for a connected simple graph occurs when all degrees are equal. For directed links, neither this degree shortcut nor symmetric-edge reasoning generally applies; solve the stationary equations for the actual directed transition matrix.
Key Takeaways
- The simple undirected walk has stationary mass proportional to degree.
- The sum of degrees is twice the number of edges.
- Connectivity gives irreducibility; bipartiteness gives period 2 for the connected simple walk.
- Laziness preserves stationary weights and removes periodicity.
- Symmetric edge weights give stationary mass proportional to total weight at each vertex.
- The undirected degree formula generally fails for directed graphs.
5.3 Build and compute a PageRank model
PageRank treats a web page's importance as the share of time a random surfer spends there. Incoming links matter through the probability they carry, so a raw count of links cannot determine the ranking.
Repair the link walk
Pages are vertices and links are directed arrows. On a page with outgoing links, the surfer chooses one uniformly. A dangling page has no outgoing links, producing a zero row. Replace that row with a uniform distribution over all pages to obtain a stochastic link matrix S.
Closed groups can still trap a pure link walk. With n pages and damping factor , introduce uniform teleportation:
where J is the all-ones matrix. With probability the surfer takes a link-walk step; otherwise it chooses a page uniformly. Brin and Page reported usually using 0.85. That is a historical model choice, not a mathematical requirement.
Every entry of G is at least . Thus G is irreducible and aperiodic and has one stationary distribution r. The normalized PageRank vector satisfies
or for each page.
Follow a four-page calculation
A links to B and C; B links to C; C links to A and D; D is dangling. After repairing D, the rows of S are
With , each page receives a teleportation contribution . Row A of G is therefore . Row D stays uniform because both parts of its mixture are uniform.
Solving the balance equations gives
C ranks first. A sends half its link contribution to C, and B sends all its link contribution there. A and D tie because each receives C's same half-contribution, with equal contributions from teleportation and D's uniform row.
Iterate without solving a large linear system
Power iteration starts with any probability row vector and repeats . Starting uniformly in the example gives approximately
The values need not approach each entry monotonically. The total absolute error contracts by at most per iteration, so it is at most times its starting value after k steps. Every eigenvalue other than 1 has absolute value at most .
Directed link walks are generally not reversible. Use the balance equations or iteration, not undirected degrees. Without teleportation this particular repaired example already converges to , with the same ordering. Teleportation ensures uniqueness and convergence for any repaired finite link graph. A column-vector source transposes G; a source scaling scores to sum to n changes their size but not their ranking.
Key Takeaways
- Replace a dangling row with a probability distribution before adding teleportation.
- Uniform teleportation with makes every Google-matrix entry positive.
- PageRank is the stationary probability vector of the Google matrix.
- An incoming link carries its source page’s rank divided across that page’s outgoing links.
- Power iteration converges from any starting distribution.
- The damping factor bounds the contraction of total absolute error.
- Score scaling changes values but preserves their ordering.
Markov Chains examples
1Build a chain from a changing system
11 steps
- 1IntroductionStart with the information that matters
A printer’s condition changes from day to day. To predict tomorrow, first decide what today’s state must record: given it, older history should add nothing (the Markov property). Then assign the possible next-day probabilities. We will build a model in Working, Broken order and use it to describe individual paths. Keeping the state definitions fixed makes every later entry readable.
- 2ExplanationSeparate the present from older history
The Markov property says that, given the present state, older states add no information about the next state’s distribution. Tomorrow can still depend strongly on today. For a printer, knowing whether it works today may matter; knowing last week’s path adds nothing once today’s full state is known.
- 3ExampleA missing detail can change the model
Suppose a recently repaired printer fails at a different rate from one that has run for many days. “Working” alone then hides useful information. Add a flag recording whether it was repaired yesterday. Two printers with the same expanded state should have the same next-state probabilities, regardless of their earlier histories.
- 4ChallengeShift the weather pair
Tomorrow’s weather depends on the last two days. If the pair state is (Rain, Dry), what must the first entry of the next pair be?
---reveal---
It must be Dry, today’s weather. The next state is (Dry, Rain) or (Dry, Dry). Pair states preserve the two days the rule needs, and shift the older day out after each step.
- 5Key InsightTime and memory are different questions
A time-homogeneous chain uses the same one-step rule at every time. The Markov property concerns which history the rule needs. A state can retain the right information even when a rule changes with the calendar; constant probabilities are an additional property. Our transition matrices use probabilities that remain fixed across steps.
- 6ExampleFill the Working row
A working printer breaks by tomorrow with probability 0.1. In Working, Broken order, the row is . The 0.9 is the probability of staying Working. A row must account for every next state, so keeping only the failure probability would leave most of the probability unassigned.
- 7ExampleAdd repair and read the matrix
A broken printer is repaired by tomorrow with probability 0.6. Its row is , giving
The entry 0.6 means Working tomorrow given Broken today. It does not reverse that conditional statement. Each row is a separate probability distribution.
- 8ConnectionDraw the same rule as arrows
Draw Working and Broken as two nodes. Add arrows Working → Broken labeled 0.1 and Broken → Working labeled 0.6. Add loops labeled 0.9 and 0.4. The outgoing labels total 1 at either node. A matrix entry of zero would have no arrow, so the diagram makes impossible moves visible.
- 9ExampleAttach the starting probability
Suppose the printer starts Working with probability 0.8. The complete path Working → Broken → Working has probability
If Working at the start were already given, the conditional path probability would be . The initial distribution matters when the event includes an uncertain starting state.
- 10ChallengeCheck the model and its path
A printer starts Broken. What is the probability of the path Broken → Working → Working, and does a row total of 1 alone verify the matrix’s state meanings?
---reveal---
The path probability is . Row totals check complete probability allocation, but entries can still be reversed or assigned to the wrong states. Read each entry against its stated current-state row and destination column.
- 11RecapA complete one-step model
Check a model in this order: the state retains the needed information, the one-step probabilities match the row and column meanings, and every row totals 1. Add an initial distribution to specify the start. A diagram displays possible moves; multiplying the probabilities along one specified route gives its path probability.
2Follow probabilities through several steps
12 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionPredict beyond tomorrow
- 2ExampleSeparate the two intermediate states
- 3ExplanationAdd routes to the same endpoint
- 4ChallengeInclude the returning route
- 5ConnectionSplit a journey into blocks
- 6TipCheck powers without recomputing every entry
- 7ExplanationAn uncertain start mixes rows
- 8ExampleAdvance the mixture again
- 9ExampleUse the gap between observations
- 10ConnectionExpected visits do not need independence
- 11ChallengeTurn a distribution into output
- 12RecapMatch the probability to the question
3Read a chain’s routes and solve its stopping questions
19 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionRead structure before calculating
- 2ExplanationLook for routes in both directions
- 3ExampleSeparate three classes
- 4ChallengeA return arrow changes class membership
- 5ExplanationAsk whether a return is certain
- 6ExampleCount returns without counting the start
- 7ChallengeA long stay can end permanently
- 8ConnectionInfinite space permits a different outcome
- 9ExplanationUse all possible return lengths
- 10ChallengeAperiodic without any loop
- 11Key InsightPeriod obstructs a common limiting row
- 12ExplanationSet the target values first
- 13ExampleSolve the class-entry probability
- 14ExampleStart the token-game equations
- 15ExampleSubstitute and solve
- 16ExplanationWaiting time adds the move just taken
- 17ConnectionCollect transient visits in one matrix
- 18ChallengeA destination and a departure time
- 19RecapChoose the right structural test
4Find equilibrium and decide whether it is approached
14 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionAn unchanged distribution can hide movement
- 2ExplanationWrite the invariant-vector condition
- 3ExampleSolve the printer ratio
- 4ExampleNormalize and check
- 5ChallengeCheck which side of the matrix to use
- 6ExplanationCount closed classes for uniqueness
- 7ExampleInterpret a return interval
- 8ConnectionAverage one long path
- 9ChallengeSeparate average visits from fixed-time chances
- 10ExplanationUse the finite convergence conditions
- 11ExampleWatch the starting-state error fade
- 12ConnectionLaziness removes a timing barrier
- 13ChallengeA unique stationary vector without irreducibility
- 14RecapKeep the long-run claims distinct
5Connect probability flow to networks and PageRank
18 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionCompare traffic in opposite directions
- 2ExplanationBalance each pair separately
- 3ExampleCirculation can preserve the state shares
- 4ChallengeA failed shortcut does not reject equilibrium
- 5ExampleUse ratios along neighboring states
- 6TipA cycle can rule reversibility out
- 7ExplanationDegrees supply the stationary weights
- 8ExampleNormalize a small graph
- 9ConnectionA triangle changes the return timing
- 10ChallengeMake the square lazy
- 11Key InsightReplace degrees by symmetric weights
- 12ExplanationRepair pages that have nowhere to go
- 13ExplanationMix links with uniform jumps
- 14ExampleBuild one Google-matrix row
- 15ExampleUpdate all pages at once
- 16Key InsightIteration has a contraction guarantee
- 17ChallengeChoose the right network shortcut
- 18RecapMatch the network to its balance rule
Markov Chains practice questions
Set 1: States, transitions, and long-run shares10 Practice Questions
Question 1 of 10
Show answerHide answer
Question 2 of 10
Show answerHide answer
Question 3 of 10
Show answerHide answer
Question 4 of 10
Show answerHide answer
Question 5 of 10
Show answerHide answer
Question 6 of 10
Show answerHide answer
Question 7 of 10
Show answerHide answer
Question 8 of 10
Show answerHide answer
Question 9 of 10
Show answerHide answer
Question 10 of 10
Show answerHide answer
Set 2: Routes, returns, and balanced flows10 Practice Questions
Save this lesson to see every answer and practice every set.
Question 1 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
Show answerHide answer
Save this lesson to see this answer.
Set 3: Combine state structure with probability calculations10 Practice Questions
Save this lesson to see every answer and practice every set.
Question 1 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
Show answerHide answer
Save this lesson to see this answer.
Set 4: Diagnose models and explain their limits10 Practice Questions
Save this lesson to see every answer and practice every set.
Question 1 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
Show answerHide answer
Save this lesson to see this answer.
Set 5: Transfer the methods to unfamiliar chains10 Practice Questions
Save this lesson to see every answer and practice every set.
Question 1 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
Show answerHide answer
Save this lesson to see this answer.
Stuck on your own question? Homework Help
Key Terms
A
Absorbing chain
Absorbing state
Accessibility
Aperiodicity
B
Balance equations
Bipartite graph
Birth–death chain
C
Chapman–Kolmogorov equations
Closed class
Communicating class
Communication
Conditional independence
Convergence to stationarity
D
Damping factor
Dangling page
Degree
Detailed balance
Diagonalization
Doubly stochastic matrix
F
First return time
First-step analysis
Fundamental matrix
G
Gambler’s ruin
Google matrix
H
Hitting probability
Hitting time
I
Initial distribution
Irreducibility
K
Kolmogorov’s cycle criterion
L
Lazy chain
Left eigenvector
Limiting distribution
Long-run average reward
Long-run visit fraction
M
Markov property
Matrix power
N
n-step transition probability
Normalization
Null recurrence
P
PageRank
Path probability
Period
Positive recurrence
Power iteration
R
Recurrence
Regular chain
Return probability
Reversibility
Row-vector convention
S
Self-loop
Simple random walk on a graph
State distribution
State reward
State space
Stationary distribution
Stationary flow
Stationary mixture
Stochastic matrix
Stochastic process
Subdominant eigenvalue
T
Teleportation
Time-homogeneous chain
Transience
Transition diagram
Transition matrix
V
Visit count
W
Weighted random walk
About this lesson
Make your own Study Materials
Turn your notes, slides and documents into Study Guides, Practice Questions, Flashcards and 6 more tools.