If we define
the most probable Q that generated O to be the single best
state sequence, then
We can compute
in a similar way as we did for
earlier. Let's first look at computing the highest probability of any
sequence of states producing O.
Let
This is fine if we just want the highest probability itself. But
often we are interested in the actual path with this probability. So
we need to keep track of this. Let's introduce a variable
to
do this.
This keeps track of the argument (state number) which maximized the
probability
at each stage.
The Viterbi algorithm can be stated inductively as follows:
Sometimes the algorithm is stated recursively:
In your implementations you must be careful to only program the iterative version. The stack overhead for the recursive version is considerable in many cases.
Since the two dimensional (
)
array
stores the most
probable state at each step, we can backtrack and find the most
probable sequence
since
Point to ponder: Think about how you can modify the above algorithm to compute the n-best paths, rather than the 1-best.