4 releases

✓ Uses Rust 2018 edition

0.3.1 Oct 7, 2019
0.3.0 Oct 7, 2019
0.2.2 Oct 6, 2019
0.2.1 Oct 6, 2019

#6 in #probability

Custom license

16KB
293 lines

mkv_chain Build Status Latest Version Rust Documentation

Stochastic Oriented Markov Chain Crate

[dependencies]
mkv_chain="0.3.1"

Example

extern crate mkv_chain;
use mkv_chain::{MarkovChain3, linalg::{Matrix3, Vec3}};
fn main() {
  let t_mat = Matrix3::new(  // Transition Matrix
    [[0.9, 0.0, 0.1],
     [0.1, 0.3, 0.6],
     [0.0, 0.1, 0.9]],
 );
 let initial = Vec3::new([0.1, 0.3, 0.6]); // Initial State
 let mvc = MarkovChain3::from(t_mat, initial);
 assert_eq!(
     mvc.take_to(3),
     Vec3::new([0.12250000000000001, 0.11130000000000001, 0.7662])
 );
}

lib.rs:

A Markov chain is a stochastic model describing a sequence of possible events in which the probability of each event depends only on the state attained in the previous event.

Example

# extern crate mkv_chain;
# use mkv_chain::{MarkovChain3, linalg::{Matrix3, Vec3}};
# fn main() {
    let t_mat = Matrix3::new(  // Transition Matrix
      [[0.9, 0.0, 0.1],
       [0.1, 0.3, 0.6],
       [0.0, 0.1, 0.9]],
   );
   let initial = Vec3::new([0.1, 0.3, 0.6]); // Initial State
   let mvc = MarkovChain3::from(t_mat, initial);
   assert_eq!(
       mvc.take_to(3),
       Vec3::new([0.12250000000000001, 0.11130000000000001, 0.7662])
   );
# }

Dependencies