Simple Markov Chain Steady State Demo
Explore the long-run behavior of small Markov chains. Enter a transition matrix, choose an initial distribution, and watch power iteration converge to the steady state distribution.
Explore Markov Chain Steady States
Enter a transition matrix to discover the long-run behavior of your Markov chain. Watch how the distribution converges to the steady state through power iteration.
Quick Start:
- Choose the number of states (2-6)
- Enter transition probabilities in the matrix
- Select an initial distribution
- Click "Compute Steady State" to run power iteration
What is a Markov Chain?
A Markov chain is a mathematical model where the next state depends only on the current state, not on the history. The steady state is the distribution the chain converges to after many steps.
Try a Preset Example
Use the "Load Preset Example" dropdown to explore common Markov chain patterns like weather transitions, absorbing states, or PageRank-style link structures.
Start by setting up your chain above
What a Markov Chain Steady State Actually Tells You
Your customer-success team tracks accounts across three states — active, at-risk, and churned — and every quarter some fraction moves between them. After enough quarters, the proportions stabilise: 55% active, 25% at-risk, 20% churned. That equilibrium is the steady state of a Markov chain, and it tells you the long-run composition of your portfolio given today’s transition matrix. The common mistake is planning headcount around this quarter’s snapshot rather than the steady state — if churn is accelerating, the current 70% active rate is temporary.
The steady state does not predict individual accounts. It predicts the aggregate distribution: if you run the system long enough with fixed transition probabilities, the fractions converge to these values regardless of where you started. That “regardless of start” property is what makes it useful for planning.
Building the Transition Matrix From Real Data
Each row of the transition matrix represents a current state; each column represents a next-period state. The entry Pij is the probability of moving from state i to state j in one step. Rows must sum to 1.0 because the system has to go somewhere. To estimate the matrix from data, count transitions: if 200 customers were active last quarter and 30 moved to at-risk, Pactive→at-risk = 30/200 = 0.15.
Two pitfalls. First, small state counts produce noisy probabilities — if only 8 customers were at-risk, one transition changes the rate by 12.5%. Use at least several quarters of data and pool the counts. Second, transition probabilities may not be stationary: a product improvement could cut the active-to-at-risk rate from 15% to 8%. If you suspect non-stationarity, compute the matrix for recent quarters separately and compare before using the steady-state result.
Reading the Convergence Path to Equilibrium
Convergence speed depends on the second-largest eigenvalue of the transition matrix. If that eigenvalue is close to 1 (say 0.95), convergence is slow — the chain takes dozens of steps to forget its starting state. If it is close to 0, convergence is fast and the steady state is reached in a few steps. For business models, slow convergence means your current customer mix will take many quarters to reach equilibrium, so short-term forecasts should not use the steady state directly.
A practical check: multiply the initial state vector by the matrix repeatedly and watch the fractions. If they stop changing (within 0.1%) by step 8, convergence is fast. If they are still drifting at step 30, the chain mixes slowly and the steady state is a long-run target rather than a near-term forecast. Plot the path — the curve from starting distribution to steady state shows exactly when each state stabilises.
Absorbing States and What They Mean for Your Model
An absorbing state is one you never leave: Pii = 1. “Churned” is often absorbing in customer models — once gone, the account does not return. When the chain has an absorbing state, the steady-state distribution puts 100% of the population in that state eventually. The interesting question shifts from “what fraction ends up where?” to “how long until everyone is absorbed?”
The fundamental matrix N = (I − Q)−1 (where Q is the sub-matrix of transient states) answers this. Each entry Nij gives the expected number of periods spent in transient state j before absorption, starting from transient state i. Sum a row of N and you get the expected time to absorption from that state. For a customer model: starting from “active,” the expected number of quarters before churn might be 12 — that is the average customer lifespan implied by the transition rates.
Common Mistakes When Setting Up a Markov Model
Rows that do not sum to 1. This is the most frequent data-entry error. If row “active” sums to 0.95, the model silently leaks 5% of the population each step. Always normalise rows after entering raw counts.
Too many states. A 10-state matrix has 100 transition probabilities to estimate. Unless you have massive data, most entries will be noisy or zero. Collapse similar states (e.g., “low risk” and “medium risk” into “at-risk”) until every row has enough observations to produce stable rates.
Assuming stationarity over years. A transition matrix estimated from 2019–2022 data may not hold in 2024 if pricing, product, or market conditions changed. Test stationarity by comparing year-over-year matrices. If the rates drift more than 3–5 percentage points, use only recent data or build a time-varying model.
Markov Chain and Steady-State Equations
Core formulas for transition dynamics, steady-state computation, and absorbing-chain analysis:
Customer State Model: Three-State Walkthrough
Scenario: A SaaS company models accounts as Active (A), At-Risk (R), or Churned (C). Quarterly transition data gives: A→A = 0.80, A→R = 0.15, A→C = 0.05; R→A = 0.30, R→R = 0.40, R→C = 0.30; C→C = 1.00 (absorbing).
Absorption analysis: Since Churned is absorbing, every account eventually churns. The transient sub-matrix Q = [[0.80, 0.15], [0.30, 0.40]]. The fundamental matrix N = (I − Q)−1 = [[7.14, 1.79], [2.14, 2.86]]. Starting from Active, expected quarters before churn = 7.14 + 1.79 = 8.93 quarters (≈ 2.2 years). Starting from At-Risk, expected quarters = 2.14 + 2.86 = 5.0 quarters.
Interpretation: An active account survives about 9 quarters on average; an at-risk account survives 5. If the success team can move the A→R rate from 15% to 10%, recalculating N shows the active lifespan jumps from 8.9 to 12.5 quarters — a 40% increase in customer lifetime from a 5-percentage-point retention improvement.
Sources
Grinstead & Snell — Introduction to Probability (Ch. 11: Markov Chains): Transition matrices, steady-state computation, and absorbing chain theory.
UC Berkeley — Markov Chain Lecture Notes: Convergence rates, eigenvalue interpretation, and mixing time analysis.
Brilliant — Markov Chains: Interactive explanations of state transitions, steady-state vectors, and absorbing states.
European Journal of Operational Research — Markov Models in Customer Analytics: Application of Markov chains to customer lifecycle modelling and CLV estimation.
Frequently Asked Questions
Why do my rows need to sum to 1?
Each row represents all possible transitions from one state. Since you must go somewhere (including staying in the same state), the probabilities must add up to 1 (100%). This tool automatically normalizes rows that don't sum to 1, but large deviations are flagged as they may indicate input errors. Understanding this helps you see why transition matrices must have rows summing to 1 and how normalization works.
What does it mean if the chain doesn't converge?
Non-convergence can happen for several reasons: periodic chains (the distribution cycles instead of settling, e.g., alternating between states), multiple absorbing states (the final state depends on which absorbing state is reached first), reducible chains (isolated groups of states have their own steady states). Try adding small self-loop probabilities (P[i][i] > 0) to break periodicity, or check that all states can reach each other. Understanding this helps you see when convergence fails and how to diagnose the issue.
Why does the steady state not depend on where I start?
For irreducible and aperiodic chains, the steady state is unique. No matter where you start, repeatedly applying the transition matrix eventually reaches the same long-run distribution. Think of it like shuffling a deck of cards: no matter the initial order, enough shuffles randomize it to the same distribution. However, for reducible chains (with isolated groups), the starting point does matter. Understanding this helps you see when initial distribution affects steady state and when it doesn't.
What is an absorbing state and why does it matter?
An absorbing state is one that, once entered, is never left (P[i][i] = 1, all other P[i][j] = 0). Examples include 'Churned' in a customer lifecycle model, 'Game Over' in a game state model, 'Retired' in an employee tenure model. If there are absorbing states and all other states can reach at least one, the steady state will have all probability concentrated in the absorbing states. The long-run question becomes 'which absorbing state will I end up in?' Understanding this helps you see how absorbing states influence long-run behavior.
How do I interpret the convergence trajectory?
The trajectory shows how the probability distribution evolves over time. Key things to look for: fast convergence (lines flatten quickly—the steady state is reached in few steps), slow convergence (lines take many iterations to stabilize—transitions are 'sticky'), oscillation (lines bounce—may indicate periodicity), different starting points converge (try different initial distributions to see them reach the same steady state). Understanding this helps you see how convergence behavior reflects chain properties.
What's the difference between L1 distance and convergence tolerance?
The L1 distance (or Manhattan distance) measures how different two distributions are by summing the absolute differences: L1 = |π_new[1] - π_old[1]| + |π_new[2] - π_old[2]| + ... The tolerance is the threshold below which we consider the chain converged. Smaller tolerance means more precision but more iterations. A tolerance of 1e-8 means the distribution changes by less than 0.000001% between iterations—effectively stable. Understanding this helps you see how convergence is measured and how tolerance affects precision.
Can I model continuous-time processes?
This tool only handles discrete-time Markov chains where transitions happen at fixed time steps. For continuous-time processes (where transitions can happen at any moment), you need: a rate matrix (Q) instead of a transition matrix (P), different mathematical methods (matrix exponentials), specialized software for continuous-time Markov chains (CTMCs). However, you can discretize a continuous process by choosing a small time step and converting rates to probabilities. Understanding this helps you see when discrete-time models are appropriate and when continuous-time models are needed.
How accurate is the 'irreducible' check?
The irreducibility check is a heuristic based on graph connectivity. It checks if all states can be reached from all other states by following positive-probability transitions. Limitations include: very small probabilities may be treated as zero, multi-step reachability isn't fully verified, for rigorous analysis, use dedicated Markov chain software. Understanding this helps you see when the heuristic is sufficient and when rigorous analysis is needed.
What if I have more than 6 states?
This demo is limited to 2-6 states for simplicity and performance. For larger chains, consider: Python with NumPy/SciPy for matrix operations, R with the markovchain package, MATLAB for large-scale linear algebra, specialized tools like PRISM for probabilistic model checking. Understanding this helps you see when this demo is sufficient and when larger-scale tools are needed.
How is this related to PageRank?
Google's PageRank algorithm is essentially computing the steady state of a Markov chain where: states are web pages, transitions follow links (with equal probability among outgoing links), a 'damping factor' adds random jumps to any page. The steady state represents the long-run probability of a random surfer being on each page—pages with higher probability are ranked higher. Try the 'PageRank-Style' preset example to explore this. Understanding this helps you see how Markov chains are used in real-world applications like web search ranking.
Related Tools
Monte Carlo Simulator
General-purpose Monte Carlo simulation for analyzing uncertainty in quantitative models.
Queueing Theory Calculator
Model waiting times and service capacity using M/M/c and other queueing models.
Project Monte Carlo Risk
Simulate project timelines and budgets using three-point estimates and discrete risks.
Smoothing & Moving Average Calculator
Apply SMA, EMA, and WMA to time series data for trend analysis and noise reduction.
Explore More Operations & Planning Tools
Build essential skills in operations research, stochastic modeling, and data-driven decision making
Explore All Data Science & Operations Tools