HashMap / tuple-backed Markov Chains
// Cargo.toml
[dependencies]
chainkov = "0.1.0"
cargo build
```rust extern crate chainkov;
use chainkov::*;
let mut m = MarkovChain::new(); // MarkovChain{ transition_prob: {} }
m.addstatechoice("a", ("b".tostring(), 1.0)); // MarkovChain { transitionprob: {"a": [("b", 0.4)]} }
m.addstatechoice("b", ("c".tostring(), 1.0)); // MarkovChain { transitionprob: {"a": [("b", 1.0)], "b": [("c", 1.0)]} }
m.addstatechoice("c", ("a".tostring(), 1.0)); // MarkovChain { transitionprob: {"c": [("a", 1.0)], "a": [("b", 1.0)], "b": [("c", 1.0)]} }
m.generatestates("a".tostring(), 4); // ["b", "c", "a", "b"]
m.nextstate("a".tostring()); // "b"
// incrementing when a state already exists m.incrementstate("a", "b"); // MarkovChain { transitionprob: {"c": [("a", 1.0)], "a": [("b", 2.0)], "b": [("c", 1.0)]} }
// incrementing when a key exists but the state transition doesn't m.incrementstate("a", "c"); // MarkovChain { transitionprob: {"c": [("a", 1.0)], "a": [("b", 2.0), ("c", 1.0)], "b": [("c", 1.0)]} }
// incrementing when a key exists but the state transition doesn't m.incrementstate("a", "c"); // MarkovChain { transitionprob: {"c": [("a", 1.0)], "a": [("b", 2.0), ("c", 1.0)], "b": [("c", 1.0)]} }
// incrementing when there is a new state in the MarkovChain m.incrementstate("e", "a"); // MarkovChain { transitionprob: {"e": [("a", 1.0)], "c": [("a", 1.0)], "a": [("b", 2.0), ("c", 1.0)], "b": [("c", 1.0)]} } ```