Expand description
Discrete-time Markov chain core.
Implements transition-matrix validation, stationary-distribution power iteration, deterministic seeded simulation, and mean first-passage-time solves. Part of the QualiaDB computational economics library (plan §5.3 / P3).
§Allocation class: HotZeroHeap
Every public kernel operates on caller-owned slices and fixed-capacity
stack arrays ([0.0f64; MAX_STATES]). No Vec, String, or Box is
constructed on the hot path. The only heap traffic is whatever the caller
chose to allocate for the input/output buffers.
§Assumptions
stationary_distribution_into assumes the chain is ergodic (aperiodic
and irreducible). Power iteration converges to the unique stationary
distribution only under that assumption; otherwise the kernel returns
MarkovError::NonConverged once the iteration budget is exhausted.
mean_first_passage_time_into likewise assumes the target state is
reachable from every other state (irreducibility); unreachable states
produce divergent hitting times and surface as NonConverged.
Enums§
- Markov
Error - Markov-chain kernel error.
Constants§
- MAX_
STATES - Maximum number of states supported by the stack-array kernels.
Functions§
- expected_
holding_ time - Expected holding time for
state:1 / (1 - P[state][state]). - mean_
first_ passage_ time_ into - Iterative solve for the mean first-passage time to
target. - simulate_
chain_ into - Deterministic seeded simulation of a Markov chain.
- stationary_
distribution_ into - Compute the stationary distribution of an ergodic Markov chain via power
iteration:
pi_{t+1} = pi_t * P. - transition_
probability - Look up
P[from][to]with bounds checking. - validate_
transition_ matrix - Validate that
pis a row-stochasticn x ntransition matrix.