AI Wiki中文/EN

Markov chains: stationary does not always mean converged

马尔可夫链

Propagate exact state probabilities and distinguish uniqueness, periodicity, time averages and detailed balance.

On this pageIntuitionMathematics & methodImplementationLimitationsExercisesResearch connections

A state is a summary of the relevant past

A small service is either quiet or busy. In a teaching model, a quiet step stays quiet with probability 4/5; a busy step becomes quiet with probability 3/10. The next-state distribution depends on the present state, not on how long the service has already been busy. That last sentence is a modeling assumption worth testing, not a property acquired by calling the states “Markov.”

If duration matters, a richer state could include elapsed time. A Markov chain need not have independent successive states: it makes a conditional statement about what information the present state retains. Read conditional probability and matrix multiplication first.

Fix the time convention and matrix orientation

For a discrete-time, time-homogeneous finite chain, Pᵢⱼ is the probability of moving from i to j in one step. The Markov property is:

Pr⁡(Xt+1=j∣Xt=i,Xt−1,…,X0)=Pijon positive-probability histories.\Pr(X_{t+1}=j\mid X_t=i,X_{t-1},\ldots,X_0)=P_{ij} \quad\text{on positive-probability histories}.

Each row of P is nonnegative and sums to one. Time-homogeneous means the same P applies at every t; a time-varying Markov process instead has a sequence of transition matrices. MIT’s Lecture 24 introduces the state, transition and conditional-memory assumptions.

We write distributions as row vectors. The law of total probability gives μₜ₊₁(j)=Σᵢμₜ(i)Pᵢⱼ, hence μₜ=μ₀Pᵗ. Pᵗ denotes a matrix power here, not a transpose. A stationary distribution is a probability row vector satisfying:

πP=π,πi≥0,∑iπi=1.\pi P=\pi,\qquad\pi_i\ge0,\qquad\sum_i\pi_i=1.

Starting at π keeps the marginal distribution unchanged at each time. It does not freeze the realized state or make successive draws independent. In our service model, π=(3/5,2/5); the stationary probability of two consecutive quiet states is(3/5)(4/5)=12/25, not(3/5)².

Solve a complete two-state example

Let aₜ be the probability of quiet at time t, starting quiet. Then aₜ₊₁=(4/5)aₜ+(3/10)(1−aₜ)=3/10+aₜ/2. Its fixed point is 3/5. Subtract that fixed point to obtain the exact trajectory:

at−35=12(at−1−35),at=35+25(12)t.a_t-\frac35=\frac12\left(a_{t-1}-\frac35\right),\qquad a_t=\frac35+\frac25\left(\frac12\right)^t.

Thus the distribution converges geometrically in this example. The formula also supplies an independent reference for repeated matrix multiplication. It is not a universal rate for all Markov chains.

Existence, uniqueness and convergence are different claims

Every finite stochastic matrix has at least one stationary distribution. If the chain is irreducible—every state can reach every other along positive-probability transitions—that distribution is unique. For convergence to it from every initial distribution, a finite irreducible chain also needs aperiodicity. The period of a state is the greatest common divisor of its possible positive return times; period 1 means aperiodic. In an irreducible chain, a positive self-loop at any state is sufficient for aperiodicity.

Aldous and Fill, Section 2.1.1, separates the time-average ergodic theorem from the distributional convergence theorem. A periodic irreducible chain can have convergent long-run occupation proportions while its distribution at a specific time keeps oscillating.

Propagate probabilities exactly

This complete Python 3.12 program supports 1–8 states, rational probability rows and 0–1000 steps. It checks row sums exactly and computes the final distribution. It does not sample a trajectory or infer transition probabilities from logs.

from fractions import Fraction as F


def propagate(matrix, initial, steps):
    p=[list(row) for row in matrix];mu=list(initial);n=len(p)
    if not 1<=n<=8 or len(mu)!=n or any(len(row)!=n for row in p):
        raise ValueError('square matrix and matching distribution, one to eight states')
    for row in p+[mu]:
        if any(type(x) not in (int,F) or not 0<=x<=1 for x in row) or sum(row,F(0))!=1:
            raise ValueError('rational nonnegative probability rows summing to one required')
    if type(steps) is not int or not 0<=steps<=1000:
        raise ValueError('integer step count in [0,1000] required')
    p=[list(map(F,row)) for row in p];mu=list(map(F,mu))
    for _ in range(steps):
        mu=[sum((mu[i]*p[i][j] for i in range(n)),F(0)) for j in range(n)]
    return mu


if __name__ == '__main__':
    p=[[F(4,5),F(1,5)],[F(3,10),F(7,10)]]
    stationary=[F(3,5),F(2,5)]
    print('stationary check:',propagate(p,stationary,1))
    for t in [0,1,2,4,8]:
        mu=propagate(p,[1,0],t)
        print('time',t,'P(state0):',mu[0],'closed form:',F(3,5)+F(2,5)*F(1,2)**t)
    flip=[[0,1],[1,0]]
    print('periodic state0 probabilities:',[str(propagate(flip,[1,0],t)[0]) for t in range(6)])
    identity=[[1,0],[0,1]]
    print('identity retains initial distribution:',propagate(identity,[F(1,4),F(3,4)],100))
    cycle=[[0,1,0],[0,0,1],[1,0,0]]
    print('directed-cycle stationary:',propagate(cycle,[F(1,3)]*3,1))

Output:

stationary check: [Fraction(3, 5), Fraction(2, 5)]
time 0 P(state0): 1 closed form: 1
time 1 P(state0): 4/5 closed form: 4/5
time 2 P(state0): 7/10 closed form: 7/10
time 4 P(state0): 5/8 closed form: 5/8
time 8 P(state0): 77/128 closed form: 77/128
periodic state0 probabilities: ['1', '0', '1', '0', '1', '0']
identity retains initial distribution: [Fraction(1, 4), Fraction(3, 4)]
directed-cycle stationary: [Fraction(1, 3), Fraction(1, 3), Fraction(1, 3)]

The flip chain alternates deterministically between two states. It is irreducible and has the unique stationary distribution(1/2,1/2), but a point-mass start does not approach it at individual times. Its time fractions still tend to 1/2. The identity matrix supplies a different failure: every starting distribution is stationary, so uniqueness fails.

The three-state directed cycle has a uniform stationary distribution but violates detailed balance: flow from 0 to 1 is 1/3, while the reverse flow is zero. Detailed balance is a useful sufficient condition for stationarity, not a necessary one. This cycle is also periodic; that is a separate property from reversibility.

Dense propagation takes O(tn²) rational operations, with O(n²) matrix storage and O(n) working probability storage. Rational bit lengths grow with repeated multiplication. Matrix exponentiation can reduce the number of matrix products for large t, while sparse methods exploit zero transitions. Neither optimization changes the stochastic model.

The state definition can be the main error

Aggregating several hidden situations into one label may destroy the Markov property. Changing usage patterns can invalidate time homogeneity. A transition table estimated from limited observations also has uncertainty; exact arithmetic on an estimated matrix does not remove it.

Stationarity alone does not say how many steps are enough. A chain may move slowly between regions while appearing stable locally. Infinite-state chains require additional recurrence and normalizability conditions; the finite irreducible theorem cannot simply be transferred. Continuous-time chains use rates and a generator rather than a probability matrix whose rows sum to one.

A Markov decision process adds actions and rewards; an uncontrolled chain does not select a policy. MCMC deliberately designs a chain to sample a target distribution, introducing a different modeling objective.

Separate three kinds of long-run statement

  1. Starting quiet, what is the probability of quiet after two steps?

Answer 1: 7/10, from either the recurrence or(4/5)²+(1/5)(3/10).

  1. Does a unique stationary distribution imply convergence from every initial state?

Answer 2: No. The two-state flip chain is a counterexample because it is periodic.

  1. What is stationary for the identity transition matrix?

Answer 3: Every probability distribution on its states.

  1. Must every stationary chain satisfy detailed balance?

Answer 4: No. The directed three-cycle preserves the uniform distribution but has unequal opposite flows.

Connect linear algebra with stochastic behavior

Matrix powers encode multi-step probabilities; communicating classes explain which states are reachable; spectral and coupling methods study convergence rates. Keep the matrix convention and the particular type of convergence explicit when comparing results.

Project: add a probability of staying put to the flip chain and derive its two-state recurrence. Compare an ordinary distribution at time t with an average of distributions from time 0 through t−1. The two calculations answer different questions, especially before periodicity is removed.

Make a prediction, then check

Does a unique stationary distribution alone guarantee convergence from every start?

Choose one answer

Learning objectives

  • Propagate a row distribution and solve a finite stationary equation.
  • Distinguish distribution convergence from stationary existence and time averages.

Prerequisites & connections

Explore related knowledge →

References

  1. Introduction to Probability — Lecture24: Finite-State Markov Chains
    John Tsitsiklis; Patrick Jaillet · 2018
  2. Reversible Markov Chains and Random Walks on Graphs — Section2.1
    David Aldous; James Allen Fill · 1999

Version1 · Editorial status: Recorded technical checks completed

View technical check record (AI)

Codex · 2026-09-06 · Codex single-agent authored technical review: cited primary-source scope, explicit assumptions, original calculations and counterexamples, runnable tests and bilingual review; not independent human or second-agent review.

  • Single-agent authored technical review: bounded primary-source locations, assumptions, original derivations, exact/literal references and matching bilingual equations/examples/exercises. Not independent human or second-agent review.
  • Four focused CPython3.12.4 tests passed per chapter. Markov and MH matrices use exact fractions; EM and BP are floating-point and tested against independent analytic or enumerated references. Seeded MCMC frequencies are an observed run, not a convergence certificate.
  • Promoted the full prose, equations, code and exercises. Tests read formal MDX only; removed temporary fallbacks/draft skips and updated review assertion to checked. Algorithm and independent references are unchanged; final record binds both locale hashes.
  • Publication navigation points published topics to complete articles and removes corresponding pending wording, retaining directory entries for unwritten targets. Principles, equations, programs and exercises are unchanged; final article SHA values rebound.

Source locations checked:

Related topics

No matches. Try a synonym or acronym.

0 results shown

Wrap the whole query in double quotes for a phrase match.