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
| Prop | Type | Default | Description |
|---|---|---|---|
| title | string | "Markov chain explorer" | Card title. |
| matrix | number[][] | 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). |
| weights | number[][] | null | null | Instead 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). |
| chain | string | "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). |
| N | number | 4 (gamblers-ruin, path-walk), 5 (cycle-walk) | Size parameter of the named chain (target fortune N or number of cycle states). |
| p | number | 0.5 | Up-step probability of the named chain. |
| states | (string | number)[] | "1".."n" ("0".."N" for named walks) | State labels (plain text, distinct). |
| initial | number[] | number | string | point mass at start | Initial law μ⁽⁰⁾: a probability vector, a state (0-based index or label), "uniform" or "stationary". |
| start | number | string | first 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. |
| target | number | string | last absorbing state, else all absorbing states | First-step view target: a state (index or label) or "absorbing" for the set of absorbing states. |
| layout | string | "auto" | State-diagram layout: auto (a line for birth-death chains, else a circle), circle or line. |
| view | string | "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). |
| views | string[] | all six | Views offered in the view switcher (the initial view is always included). |
| steps | number | 20 | Time horizon of the distribution plot and the range of the power sliders (1 to 100). |
| time | number | 0 | Distribution view: initial time n. |
| m | number | 1 | Powers view: initial m in P^(m+n) = P^m P^n. |
| n | number | 1 | Powers 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. |
| presetLabel | string | "Original" | Dropdown label of the chain given by the top-level props. |
| seed | number | string | 1 | Seed for simulated walks (same seed, same paths). |
| editable | boolean | true | Let the learner edit matrix entries and (in the classify view) add or delete arrows. |
| showProduct | boolean | true | Distribution view: write out μ⁽ⁿ⁾ = μ⁽ⁿ⁻¹⁾P with numbers. |
| showCesaro | boolean | false | Distribution view: start with the Cesàro averages drawn. |
| showCanonical | boolean | false | Classify view: start with the canonical block form shown. |
| showTransitionCounts | boolean | false | Walk view: start with the one-step transition tally shown. |
| walkSteps | number | 0 | Walk view: number of steps already simulated when the card loads (0 to 19999), so the page can open on a long path. |
| quantity | string | "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). |
| controls | string[] | all controls shown | Registry 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. |