Expand description
§Hidden Markov Model
§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
Question: If we now get observation of H H T T T which coins were used during each toss?
Lest build HMM model for this example and check the answer:
let initials: Vec<f64> = vec![0.5, 0.5];
let st = vec![0.75, 0.25, 0.25, 0.75];
let obs = vec![0.5, 0.5, 0.25, 0.75];
let hmm = HiddenMarkov::from_vec(initials, st, obs).unwrap();
hmm.map_estimate(vec![0, 0, 1, 1, 1]) == vec![0, 0, 1, 1, 1]
Structs§
- Specialized structure for Hidden Markov Model of order 1 The states are identified by ids taken from natural numbers.