M4.0 Tomorrow Depends on Today: Markov Chains and Transition Matrices
Start with a weather record
A city’s records suggest an 80% chance of sunshine after a sunny day and a 40% chance after a rainy day. Ignore seasons and earlier history for now.
Treat these as fixed daily rules depending only on today’s weather. Starting sunny, ask:
- What is the probability that all three following days are sunny?
- What is the probability that day 100 is sunny? How much does today’s state still matter?
The first event follows one path. The second includes paths that become rainy and return to sunshine. How can we sum all intermediate possibilities? Propagate a distribution through a transition table.
DiscussionQ1
Define the random variables, the requested probabilities, and the “today alone” assumption.
Show the reasoning
Let denote day ‘s weather. The sequence is a stochastic process.
The “today alone” assumption is
Given the current state, further past information does not change the next-state law: the Markov property. A separate assumption, time homogeneity, says these conditional transition probabilities do not depend on the day index.
The first question asks ; the second asks . The initial law and one-step rules determine both under these assumptions.
Tokens moving between two squares
A token on the sunny square stays with probability 0.8; on the rainy square it stays with probability 0.6. The rule does not track how long it has occupied that square.
Start a thousand independent tokens on sunshine. About 800 remain after one step. Next, about occupy sunshine. Repeated updating approaches a fixed allocation. We want both that allocation and the rate of approach.
This chain approaches a stationary distribution; convergence is a property to check, not a consequence of every transition matrix.
Write the picture as a matrix
Rows represent today; columns represent tomorrow:
A transition matrix has nonnegative entries and each row sums to one. Such a matrix is row-stochastic.
Represent the current law by a row vector . Then
This is total probability over today’s possible states. Repeating the update gives
Matrix multiplication sums intermediate paths: . This Chapman–Kolmogorov identity composes transitions.
For three consecutive sunny days, the Markov property gives
The product relies on the state containing sufficient history. If a long sunny run changes tomorrow’s probability, the two-state rule no longer suffices.
An unchanged allocation
A probability row vector satisfying
is stationary. Here becomes : equal flows in both directions. Together with normalization this gives
A stationary law is a nonnegative normalized left eigenvector with eigenvalue one. Every finite stochastic matrix has at least one stationary law; irreducibility makes it unique.
How quickly is today forgotten?
Let . Since , we obtain
Starting sunny, this gives . The factor is the second eigenvalue. Initial-state influence shrinks by that factor daily, becoming extremely small by day 100.
The answer is extremely close to , rather than one half or 0.8. Long-run proportions balance both transition directions: .
DetailsGeneral convergence and spectral qualifications
A finite irreducible aperiodic chain has a unique stationary law and converges to it from every initial distribution [1,3]. The two-state error here is exactly proportional to 0.4^n. General matrices can have Jordan-block polynomial factors. If all nontrivial eigenvalues have modulus at most r less than one, any ρ strictly between r and one permits a bound Cρ·ρ^n. Diagonalizable, especially reversible, chains admit more direct spectral bounds.
The ergodic theorem also says a single long trajectory’s visit fraction converges almost surely to its stationary probability. This is why many independent tokens and one long record estimate the same proportion.
Revisit the two questions
Three consecutive sunny days have probability . Day 100 has probability from a sunny start. Finite-time dependence is tiny rather than exactly absent.
Seasonal rules require time-varying transition matrices. History dependence requires augmenting the state. Periodicity can prevent convergence despite stationarity: deterministic alternation has stationary law , but a pure initial state alternates forever.
Try it
Check the consecutive-event probability, long-run proportion , and daily contraction factor . Then introduce a history-dependent rule.
import numpy as np
rng = np.random.default_rng(0)
P = np.array([[.8,.2],[.4,.6]])
N, x = 200000, 0
path = np.empty(N,dtype=int)
for n in range(N):
x = rng.choice(2,p=P[x])
path[n] = x
print('long-run sunny fraction:',(path==0).mean())
p = np.array([1.,0.])
for n in range(1,6):
p = p@P
print(n,p[0],p[0]-2/3)
Check your understanding
References
- Norris, J. R. Markov Chains. Cambridge University Press, 1997.
- Grimmett, G., Stirzaker, D. Probability and Random Processes, 3rd ed. Oxford University Press, 2001.
- Levin, D. A., Peres, Y. Markov Chains and Mixing Times, 2nd ed. AMS, 2017.