hmm 0.2.0

Hidden Markov Model
Documentation
  • Coverage
  • 100%
    5 out of 5 items documented1 out of 5 items with examples
  • Size
  • Source code size: 28.23 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 472.05 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Homepage
  • klangner/hmm
    8 1 2
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • klangner

Hidden Markov Model

Crates.io Crates.io docs.rs

hmm is an early-stage open-source project. It means that API can change at any time. If you think that this library can help you, then let me know. We can discuss future direction and try to stabilize the API.

Features

  • Viterbi MAP estimation

Example

Lets say that we have 2 coins:

  • Fair which generates H (Head) and T (Tails) with probability of 1/2
  • Biased - with probabilities H: 1/4, T: 3/4

We also know that after each toss we can switch coin with the probability of

  • Use the same coin: 3/4
  • Switch coin: 1/4

First time we select coin with probability of 1/2

Using this library we can answer the following question:

Given the observations 'H H T T T' which coins were used during each toss?

Lest build HMM model and check the answer:

extern crate hmm;

use hmm::models::{HiddenMarkov};


fn main() {
    let initials = vec![0.5, 0.5];
    let st = vec![ vec![0.75, 0.25],
                   vec![0.25, 0.75]];
    let obs = vec![ vec![0.5, 0.5],
                    vec![0.25, 0.75]];
    let hmm = HiddenMarkov::new(initials, st, obs).unwrap();
    let coins = hmm.map_estimate(vec![0, 0, 1, 1, 1]);
    println!("Coins used: {:?}", coins);
}

For more check Examples.

License

Licensed under either of

at your option.

Contributions

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.