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 Encoding

Custom license

16KB
293 lines

markov-chain-rs

Markov chain package for computing probabilistic events

Docs

here

Example

extern crate markov_chain;
use markov_chain::{MarkovChain3, alg::{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]); // Inital State
  let mvc = MarkovChain3::from(t_mat, initial);
  assert_eq!(
      mvc.take_to(3),
      Vec3::new([0.12162, 0.09832199999999999, 0.6612132])
  );
}

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