Code covered by the BSD License  

Highlights from
Forward Viterbi Algorithm

3.0 | 3 ratings Rate this file 21 Downloads (last 30 days) File Size: 1.83 KB File ID: #24516
image thumbnail

Forward Viterbi Algorithm


David Conger


22 Jun 2009 (Updated )

Forward Viterbi algorithm based on:

| Watch this File

File Information

Forward Viterbi algorithm based on the Python code found at:

Also included is an example based on the one from the Wikipedia page for a simple 2-state model with 4 observations. To paraphrase:

Bob tells Alice his daily activities (observations) and Alice wants to determine the most likely weather each day (states). Since Alice lives far away, the weather is unknown to her (hidden). Assuming that the states behave as a Markov process, and the observations have a statistical dependency on the states, the Viterbi algorithm can find the most likely weather pattern (path).

More information can be found at:

MATLAB release MATLAB 7.5 (R2007b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (3)
04 Aug 2010 Sam Ham

Sam Ham

The code works fine now, the previous bug was fixed, I just tested it.

04 Aug 2010 Sam Ham

Sam Ham

05 Nov 2009 Justin


foward_viterbi.m contains a bug not in the original python version. If the output is longer than 3 states then this line throws an error. The 2nd index to emit_p should be the position of the output token in the vector of possible output states, not the index into the observation vector.
p = emit_p(source_state,output) * trans_p(source_state,next_state);

12 Jan 2010

Fixed the problem found by Justin. To make things simpler, observations are now numbered, rather than allowing strings.

Contact us