View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Forward Viterbi Algorithm

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

Forward Viterbi Algorithm



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 (4)
29 Jul 2016 GC

GC (view profile)

Dear sir
I run forward-viterbi with an observation sequence of 2 elements.
The output is sequence of 3 states and compute the probability of this sequence.
In fact the sequence of the best states is right but there is one element more and the probabilty correspond with the sequence with this extra state.
Sincerely yours

Comment only
04 Aug 2010 Sam Ham

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

04 Aug 2010 Sam Ham

05 Nov 2009 Justin

Justin (view profile)

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 1.1

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

Contact us