pub struct MarkovChain {
pub states: usize,
pub transition: Vec<Vec<f64>>,
}Expand description
Discrete-time, finite-state Markov chain with mixing time estimation.
Fields§
§states: usizeNumber of states.
transition: Vec<Vec<f64>>Row-stochastic transition matrix: transition[i][j] = P(i → j).
Implementations§
Source§impl MarkovChain
impl MarkovChain
Sourcepub fn new(transition: Vec<Vec<f64>>) -> Self
pub fn new(transition: Vec<Vec<f64>>) -> Self
Creates a new MarkovChain from a row-stochastic transition matrix.
Sourcepub fn stationary_distribution(&self) -> Vec<f64>
pub fn stationary_distribution(&self) -> Vec<f64>
Computes the stationary distribution via power iteration.
Returns a distribution π such that π P = π.
Sourcepub fn mixing_time(&self, epsilon: f64) -> usize
pub fn mixing_time(&self, epsilon: f64) -> usize
Estimates the ε-mixing time: smallest t such that max_i d_TV(P^t(i, ·), π) ≤ ε.
Sourcepub fn is_ergodic(&self) -> bool
pub fn is_ergodic(&self) -> bool
Checks whether the chain is ergodic (all states communicate).
Auto Trait Implementations§
impl Freeze for MarkovChain
impl RefUnwindSafe for MarkovChain
impl Send for MarkovChain
impl Sync for MarkovChain
impl Unpin for MarkovChain
impl UnsafeUnpin for MarkovChain
impl UnwindSafe for MarkovChain
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more