Viterbi algorithm: Difference between revisions

Content deleted Content added
Pseudocode: Separated algorithm description/explanation and pseudocode implementation.
Example: fix systaxhighlight error
Line 69:
 
The ''observations'' (normal, cold, dizzy) along with the ''hidden'' states (healthy, fever) form a hidden Markov model (HMM). From past experience, the probabilities of this model have been estimated as:
<pre>
<syntaxhighlight>
init = {"Healthy": 0.6, "Fever": 0.4}
trans = {
Line 79:
"Fever": {"normal": 0.1, "cold": 0.3, "dizzy": 0.6},
}
</pre>
</syntaxhighlight>
In this code, <code>init</code> represents the doctor's belief about how likely the patient is to be healthy initially. Note that the particular probability distribution used here is not the equilibrium one, which would be <code>{'Healthy': 0.57, 'Fever': 0.43}</code> according to the transition probabilities. The transition probabilities <code>trans</code> represent the change of health condition in the underlying Markov chain. In this example, a patient who is healthy today has only a 30% chance of having a fever tomorrow. The emission probabilities <code>emit</code> represent how likely each possible observation (normal, cold, or dizzy) is, given the underlying condition (healthy or fever). A patient who is healthy has a 50% chance of feeling normal; one who has a fever has a 60% chance of feeling dizzy.