Markov Chain Explorer

The learner explores a finite Markov chain drawn as a state diagram next to its (editable) transition matrix: steps or animates μ⁽ⁿ⁾ = μ⁽ⁿ⁻¹⁾P toward π, expands Pⁿ entries by Chapman-Kolmogorov, simulates a walk with visit and transition frequencies, sees communicating classes, recurrence and periods change as arrows are added or deleted, solves first-step equations for absorption probabilities and hitting times (checked by simulation), and compares the flows π_i p_ij and π_j p_ji for detailed balance.

Used in: Introduction to Probability Theory

Props

PropTypeDefaultDescription
titlestring"Markov chain explorer"Card title.
matrixnumber[][]weather chain [[0.8,0.2],[0.4,0.6]]Row-stochastic transition matrix, P[i][j] = P(X_{n+1} = j | X_n = i), 1 to 12 states. Rows that do not sum to 1 are normalised (with a note).
weightsnumber[][] | nullnullInstead of matrix: edge weights of a graph; the chain is the random walk p_ij = w_ij / sum_k w_ik (symmetric weights give a reversible chain).
chainstring"weather"Named chain used when neither matrix nor weights is given: weather (Sunny/Rainy), gamblers-ruin (0..N, absorbing ends), cycle-walk (N states on a cycle, +1 w.p. p), path-walk (reflecting lazy walk on 0..N), flip (strict alternation of two states).
Nnumber4 (gamblers-ruin, path-walk), 5 (cycle-walk)Size parameter of the named chain (target fortune N or number of cycle states).
pnumber0.5Up-step probability of the named chain.
states(string | number)[]"1".."n" ("0".."N" for named walks)State labels (plain text, distinct).
initialnumber[] | number | stringpoint mass at startInitial law μ⁽⁰⁾: a probability vector, a state (0-based index or label), "uniform" or "stationary".
startnumber | stringfirst state (middle state for gamblers-ruin)Start state (0-based index or label) for the walk and first-step views; a point-mass initial sets it too.
targetnumber | stringlast absorbing state, else all absorbing statesFirst-step view target: a state (index or label) or "absorbing" for the set of absorbing states.
layoutstring"auto"State-diagram layout: auto (a line for birth-death chains, else a circle), circle or line.
viewstring"distribution"Initial view: distribution (step μ⁽ⁿ⁾ = μ⁽ⁿ⁻¹⁾P), powers (Pⁿ and Chapman-Kolmogorov), walk (simulated path, visit and transition frequencies), classify (classes, recurrence, periods, add/delete arrows, canonical form), first-step (absorption probabilities, expected hitting times, simulation check) or balance (detailed balance flows).
viewsstring[]all sixViews offered in the view switcher (the initial view is always included).
stepsnumber20Time horizon of the distribution plot and the range of the power sliders (1 to 100).
timenumber0Distribution view: initial time n.
mnumber1Powers view: initial m in P^(m+n) = P^m P^n.
nnumber1Powers view: initial n.
cell[number, number] | null[0, 1]Powers view: the entry (i, j) of P^(m+n) that is expanded as a sum over intermediate states (0-based).
presets{name, matrix | weights | chain, N?, p?, states?, initial?, start?, target?, layout?}[][]Further example chains offered in a Chain dropdown next to the original. A same-size matrix preset keeps the original labels and initial law.
presetLabelstring"Original"Dropdown label of the chain given by the top-level props.
seednumber | string1Seed for simulated walks (same seed, same paths).
editablebooleantrueLet the learner edit matrix entries and (in the classify view) add or delete arrows.
showProductbooleantrueDistribution view: write out μ⁽ⁿ⁾ = μ⁽ⁿ⁻¹⁾P with numbers.
showCesarobooleanfalseDistribution view: start with the Cesàro averages drawn.
showCanonicalbooleanfalseClassify view: start with the canonical block form shown.
showTransitionCountsbooleanfalseWalk view: start with the one-step transition tally shown.
walkStepsnumber0Walk view: number of steps already simulated when the card loads (0 to 19999), so the page can open on a long path.
quantitystring"absorption" if there is an absorbing state, else "hitting"First-step view: absorption (h_i = P(absorbed at the target)) or hitting (m_i = expected steps to reach the target).
controlsstring[]all controls shownRegistry ids of the hideable controls and text to show (see `controls` in this file): the powers / classify / first-step / balance views (view.*; the distribution and walk views and the page's own view always show), the π reference and TV readouts, the Cesàro and transition-count toggles, the classify view's class, recurrence, period and absorbing readouts, the canonical form toggle, the row-gap row and the hitting-time option. Core controls always show. Absent = everything. Fitted per page by component_scopes.py, not by hand.