1 This is a quick description of the viterbi aka dynamic programing
4 Its reason for existence is that wikipedia has become very poor on
5 describing algorithms in a way that makes it useable for understanding
6 them or anything else actually. It tends now to describe the very same
7 algorithm under 50 different names and pages with few understandable
8 by even people who fully understand the algorithm and the theory behind.
10 Problem description: (that is what it can solve)
11 assume we have a 2d table, or you could call it a graph or matrix if you
23 That table has edges connecting points from each column to the next column
24 and each edge has a score like: (only some edge and scores shown to keep it
28 O--5--O-----O-----O-----O-----O
31 O7-/--O--/--O--/--O--/--O--/--O
32 \/ \/ 1/ \/ \/ \/ \/ \/ \/ \/
33 /\ /\ 2\ /\ /\ /\ /\ /\ /\ /\
34 O3-/--O--/--O--/--O--/--O--/--O
37 O--2--O--1--O--5--O--3--O--8--O
41 Our goal is to find a path from left to right through it which
42 minimizes the sum of the score of all edges.
43 (and of course left/right is just a convention here it could be top down too)
44 Similarly the minimum could be the maximum by just fliping the sign,
45 Example of a path with scores:
53 O O O O O O-1-O---> (sum here is 24)
56 The viterbi algorthm now solves this simply column by column
57 For the previous column each point has a best path and a associated
72 To move one column forward we just need to find the best path and associated
73 scores for the next column
74 here are some edges we could choose from:
88 Finding the new best pathes and scores for each point of our new column is
89 trivial given we know the previous column best pathes and scores:
103 the viterbi algorthm continues exactly like this column for column until the
104 end and then just picks the path with the best score (above that would be the
108 Author: Michael niedermayer