Next: Forward and Backward Probabilities
Up: Hidden Markov Models
Previous: Hidden Markov Models
Viterbi Algorithm
We can calculate the optimal path in a hidden Markov model using a
dynamic programming algorithm. This algorithm is widely known as
Viterbi Algorithm. Viterbi [10] devised this
algorithm for the decoding problem, even though its more general
description was originally given by Bellman [3].
Given a sequence X, denote vk(i) to be the probability of
the most probable path for the prefix
that
ends with the state k (
and
).
- 1.
- Initialize:
vbegin(0) |
= |
1 |
(6.12) |
|
= |
0 |
(6.13) |
- 2.
- For each
and for each
recursively calculate:
|
(6.14) |
- 3.
- Finally, the value of
is:
|
(6.15) |
We can reconstruct the path
itself by keeping back pointers during the
recursive stage and tracing them.
Complexity: We calculate the values of
cells of the matrix V, spending O(|Q|) operations per cell.
The overall time complexity is therefore
and
the space complexity is
.
Since we are dealing with probabilities, the extensive
multiplication operations we perform may result in an underflow.
This can be avoided if we choose to work with logarithmic scores.
We can therefore define vk(i) to be the logarithmic score of
the most probable path for the prefix
that
ends in the state k.
We shall initialize:
vbegin(0) |
= |
0 |
(6.16) |
|
= |
|
(6.17) |
The recursion will look like:
|
(6.18) |
Finally, the score for the best path
is:
|
(6.19) |
Next: Forward and Backward Probabilities
Up: Hidden Markov Models
Previous: Hidden Markov Models
Itshack Pe`er
1999-01-24