An absorbing Markov chain is a stochastic (random) process that moves between a finite set of states from one step to the next. At least one of these states is absorbing, meaning that once the process enters it, it stays there forever. All other states are called transient: starting from a transient state, there is a nonzero probability that the process will eventually be absorbed.
This calculator helps you analyze such chains from their transition matrix. Given a matrix of step-by-step transition probabilities and a list of absorbing states, it computes:
The tool is limited to a 5×5 transition matrix, but the underlying method is the standard absorbing Markov chain theory used in probability, statistics, and stochastic modeling.
Suppose you have n states labeled 0, 1, …, n − 1. The transition matrix P is an n×n matrix where entry P[i,j] is the probability of moving from state i to state j in one step. Each row represents a probability distribution, so each row must sum to 1 (within numerical rounding).
For an absorbing Markov chain, we can conceptually reorder the states so that all transient states come first and all absorbing states come last. In that ordering, the transition matrix can be written in block form as:
Here:
Q is the submatrix of probabilities for transitions from transient states to transient states.R is the submatrix of probabilities for transitions from transient states to absorbing states.I is an identity matrix representing that once you are in an absorbing state you stay there with probability 1.The key object for analysis is the fundamental matrix N, defined by
Interpreting N:
N[i,j] is the expected number of visits to transient state j if the chain starts in transient state i, before absorption.N give the expected number of steps until absorption from each transient state.Once N is known, we can compute the matrix of absorption probabilities
In B, entry B[i,k] is the probability that, starting from transient state i, the chain will eventually be absorbed in absorbing state k. Each row of B represents a full probability distribution over absorbing states, conditional on the starting transient state.
0,3,4. Each absorbing state should have probability 1 of transitioning to itself and 0 to all other states in its row.Q and R submatrices internally.N).If you leave the absorbing-states field blank, the tool treats that as resetting your selection. To get meaningful output, you must specify at least one absorbing state and at least one transient state.
Consider a simple 3-state system (we embed it in the 5×5 matrix by leaving unused rows/columns in their default form). Suppose:
Use the following nonzero entries in the top-left 3×3 block:
P(0 → 0) = 0.2, P(0 → 1) = 0.5, P(0 → 2) = 0.3P(1 → 0) = 0.1, P(1 → 1) = 0.4, P(1 → 2) = 0.5P(2 → 2) = 1.0 (absorbing), with all other transitions from 2 equal to 0Set the absorbing-states field to 2. The calculator will treat 0 and 1 as transient, and 2 as absorbing. Internally, the Q and R matrices are:
Q = [[0.2, 0.5], [0.1, 0.4]] (transient → transient)R = [[0.3], [0.5]] (transient → absorbing)The calculator inverts I − Q to get N, then computes B = N R. The output will tell you, for example:
By adjusting the matrix, you can model scenarios such as random walks with absorbing boundaries, customer life cycles with "churned" or "retained" absorbing states, or reliability systems where failure is absorbing.
Once you have run the calculator, use the outputs as follows:
N[i,i] is large, the process tends to spend many steps in state i when starting from that same state.| Quantity | Matrix symbol | What it represents |
|---|---|---|
| Transition matrix | P |
Full step-by-step transition probabilities between all states in the chain. |
| Transient-to-transient block | Q |
Probabilities of moving among transient states before absorption. |
| Transient-to-absorbing block | R |
Probabilities of jumping from transient states directly into absorbing states. |
| Fundamental matrix | N = (I − Q)−1 |
Expected number of visits to each transient state, starting from each transient state. |
| Absorption probabilities | B = N R |
Probability of ending in each absorbing state, given the starting transient state. |
| Expected steps to absorption | Row sums of N |
Expected number of transitions until some absorbing state is reached. |
I − Q is nearly singular (for example, if the chain almost never leaves certain regions), numerical inversion may be unstable. Very large entries in N or extremely large expected times may reflect this sensitivity.Within these constraints, the calculator provides a quick way to explore absorbing Markov chains, understand expected times to certain outcomes, and compare different configurations of transition probabilities.
A Markov chain is a stochastic process that hops between states with probabilities that depend only on the current state. Among the many varieties of Markov chains, absorbing chains occupy a special place. An absorbing chain contains at least one state that, once entered, cannot be left. These states are called absorbing states. Formally, a state is absorbing if , where denotes the transition matrix. All other states are called transient because the chain will eventually leave them.
To analyze an absorbing chain, we reorder the states so that all absorbing states come last. The transition matrix then takes a canonical block form:
Here, is a square matrix describing transitions among transient states, gives probabilities of moving from transient to absorbing states, and is an identity matrix corresponding to staying in an absorbing state once reached. The zero block indicates that absorbing states have no transitions back to transient states.
The fundamental matrix of an absorbing chain is defined as . Each entry of gives the expected number of times the chain visits transient state starting from transient state . Summing a row of yields the expected number of steps before absorption when starting from that transient state. Multiplying by yields a matrix whose entries give the probability of absorption in absorbing state given that the chain starts in transient state .
The calculations this calculator performs mirror standard textbook treatments. After you input the transition matrix and specify which states are absorbing, the script rearranges the matrix into the form, inverts , and computes expected step counts and absorption probabilities. All computations occur client‑side using plain JavaScript, making the tool self‑contained and suitable for offline use.
Consider a simple board game in which a token moves along four squares and then reaches an absorbing finish. At each step the token either advances or stays put, depending on a die roll. We can model this with the following transition matrix:
State 4 is absorbing. The corresponding matrix consists of the top‑left 4×4 block, while is a 4×1 column vector giving the probabilities of transitioning to state 4. Calculating and yields insight into how long the game lasts and the likelihood of finishing, though in this simple example absorption is certain.
| Transient State | Expected Steps to Absorption |
|---|---|
| 0 | 8 |
| 1 | 6 |
| 2 | 4 |
| 3 | 2 |
The table illustrates a pattern: the further the starting state is from the absorbing state, the more steps the process expects to take. These numbers correspond to the row sums of the fundamental matrix. In general, if the transition probabilities vary, the expected times can exhibit non‑linear behavior, emphasizing the importance of computational tools.
The derivation of begins with the series expansion of :
Each term gives the probabilities of transitioning between transient states in exactly steps without absorption. Summing this infinite geometric series yields , provided the spectral radius of is less than one—a condition guaranteed for absorbing chains. This representation connects probabilistic intuition with linear algebra.
Once is known, other quantities follow. The expected number of steps before absorption starting from transient state is . Writing this in vector form with as a column of ones gives . The matrix of absorption probabilities is , as noted earlier. These formulas make computation straightforward once we have routines for matrix multiplication and inversion.
To use this tool, fill in the 5×5 transition matrix with probabilities. Each row should sum to one, reflecting total probability. Then list the indices of absorbing states separated by commas. When you click the button, the script extracts the sets of transient and absorbing states, forms matrices and , and computes , the expected steps vector, and the absorption probability matrix. Results are displayed in tables: one for expected steps and another for absorption probabilities.
The calculator handles up to five states for readability, but the underlying mathematics extends to larger systems. For large matrices, numerical issues such as rounding errors can arise during inversion. Our implementation uses a Gauss–Jordan elimination routine with a tolerance for tiny pivots, sufficient for educational use. In professional settings, numerical libraries with enhanced stability are recommended.
Absorbing Markov chains model a wide range of phenomena. In ecology, they describe the progression of an organism through life stages culminating in death. In finance, certain credit rating models allow default as an absorbing state. In board games like Monopoly, landing in jail can be treated as an absorbing state for some analyses. By computing expected times and absorption probabilities, analysts can quantify how long processes persist and which terminal states are most likely.
For example, consider a customer churn model where customers transition among loyalty levels before eventually leaving. States representing active customers are transient, while a “churned” state is absorbing. The fundamental matrix then reveals the expected lifetime of a customer and the probability of eventual churn from each starting level. Such insights inform marketing strategies and resource allocation.
Another application appears in reliability engineering. Components may pass through stages of wear before failure; failure is absorbing. By modeling transitions based on observed data, engineers estimate expected lifetimes and the distribution of failure modes. Similarly, in health care, disease progression can be modeled as an absorbing chain where recovery or death are absorbing states. The expected time in each health state and the probabilities of each outcome aid treatment planning.
While absorbing chains eventually terminate, the path to absorption can be complex. Some chains exhibit almost‑absorbing behavior where the expected number of steps is large despite certain absorption. The fundamental matrix captures this by summing over all possible visits to transient states. If the spectral radius of is close to one, the entries of grow large, indicating prolonged wandering before absorption.
Interpreting the absorption probability matrix requires attention. Rows correspond to starting transient states and columns to absorbing states. Each row sums to one, reflecting the certainty of eventual absorption somewhere. Disparities among columns reveal which absorbing states dominate given a starting point. If certain absorbing states are undesirable—say, system failure versus successful completion—these probabilities guide interventions aimed at steering the process.
The JavaScript code constructs matrices as arrays of arrays. To invert , it augments the matrix with the identity and performs Gauss–Jordan elimination. Matrix multiplication routines carry out the necessary products for , , and . All calculations are performed in double‑precision floating point, which suffices for most educational examples.
To ensure robustness, the code includes basic checks: if no absorbing states are provided or if all states are absorbing, the script reports that analysis cannot proceed. Similarly, if the transition matrix is ill‑formed—for example, rows not summing to one—the results may not represent a valid Markov chain. While the script does not enforce row sums exactly, users are encouraged to input proper stochastic matrices.
Experimenting with different matrices reveals interesting behavior. Chains with multiple absorbing states can show strong sensitivity to initial conditions. By observing how absorption probabilities vary with starting state, one gains intuition about the dynamics. The expected steps table highlights which states serve as bottlenecks or traps, where the process lingers.
Ultimately, absorbing Markov chains blend linear algebra with probability, yielding insights applicable across disciplines. This calculator aims to demystify the computations by automating matrix operations and presenting results clearly. The extensive explanation above, complete with MathML formulas and tables, serves as a reference for students and practitioners alike. By engaging with the tool, you can explore how transitions accumulate, how long processes persist, and where they end up. Such understanding is invaluable in fields ranging from economics to epidemiology, demonstrating the broad utility of absorbing Markov chain analysis.
Save the computed tables of expected steps and absorption probabilities in your notes or research log. Keeping these matrix snapshots lets you revisit assumptions and compare how changes in transition probabilities alter long-term behavior.
| Starting state | Absorb in state 3 | Absorb in state 4 | Absorb in state 0 |
|---|---|---|---|
| 1 (transient) | 0.62 | 0.33 | 0.05 |
| 2 (transient) | 0.20 | 0.70 | 0.10 |
| 3 (absorbing) | Already absorbed | ||
Tables like this help you rank starting states by risk. If the "failure" column dominates, consider changing transitions or adding a control policy that nudges the process toward safer absorbing states. Pair the absorption view with the expected steps summary to identify whether riskier states also keep the system occupied longer.
Continue exploring stochastic modeling with the Markov chain steady state tool for long-run behavior, matrix inverse calculator for manual verification of inversions, and the matrix multiplication helper to practice composing transition powers.