0

I am trying to understand Viterbi Algorithm.

The states are; S1, S2, S3, BEGIN, END

The values are rounded and truncated.

The smoothed State transition table is as follows;

  S1  S2  S3 B E

S1 -0.7 -1.6 -1.6 -INF -2.0

S2 -2.0 -1.3 -0.7 -INF -2.0

S3 -1.3 -0.7 -2.0 -INF -2.0

B -1.2 -1.2 -1.2 -INF -1.9

E -INF -INF -INF -INF -INF

The smoothed emission table from states to red, green, blue;

  RED GREEN BLUE

S1 -0.9 -1.2 -1.6

S2 -1.6 -0.9 -1.2

S3 -1.6 -1.6 -0.6

B -INF -INF -INF

E -INF -INF -INF

The question is; Symbols have been seen are; RED RED GREEN BLUE

what are the most likely states?

Therefore;

I created the Viterbi algorithm matrix according to values above;

First row represent the S1, S2, S3 values when RED symbol seen, just like that rest of rows for S1,S2,S3 values when red, green and blue seen.

For the first row I calculated it;

values are smoothed by taking natural logarithms of them therefore I am adding values instead of multiplying.

For the first red seen;

δ(S1) = MAX{P(S1|B)+P(R|S1)+δ(B)} = -1.2 - 0.9 + 0= -2.1

δ(S2) = MAX{P(S2|B)+P(R|S2)+δ(B)} = -1.2 - 1.6 + 0= -2.8

δ(S3) = MAX{P(S3|B)+P(R|S3)+δ(B)} = -1.2 - 1.6 + 0= -2.8

Just like above, for the next red seen;

δ(S1) = MAX{ (P(S1|S1)+P(R|S1)+δ(S1) ), ( P(S1|S2)+P(R|S2)+δ(S2) ), ( P(S1|S3)+P(R|S3)+δ(S3) )}

= MAX{ (-0.7-0.9-2.1),(-1.6-1.6-2.8), (-1.6-1.6-2.8) } = MAX{-3.7, -6, -6}

The maximum is -3.7 therefore S1 value when RED is seen; -3.7 . Rest of the values are calculated as above.

Viterbi Algorithm Matrix;

  S1  S2  S3 B E

RED -2.1 -2.8 -2.8 -INF -INF

RED -3.7 -5.2 -5.2 -INF -INF

GREEN -5.8 -6.3 -7.0 -INF -INF

BLUE -8.1 -8.6 -7.8 -INF -INF

The answer of this example shows that most likely states are; S1, S1, S2, S3

However shouldn't it be; S1, S1, S1, S3? Because maximum value for the first red is -2.1 which is belong S1 and for second red it is again S1, and for the third one again S1 value is highest and for the blue S3 value is the highest. I can be wrong because I actually couldn't understand the dynamic programming approach for Viterbi.

yns
  • 440
  • 2
  • 8
  • 28
  • What's going on here? Your tables should contain *probabilities*, i.e. values in [0,1], not -INF and whatever? Please explain. – davidhigh May 10 '14 at 21:38
  • My table contains probabilities but the values are smoothed by taking natural logarithms of it that is why it is negative. There are infinities because there is no transition between those states or symbols and states. – yns May 10 '14 at 23:16

1 Answers1

1

You should begin to trust well-established algorithms ;-). Seriously, you made no mistake in the calculation of the first two steps, and as the algorithm proceeds in the same way, I guess you haven't either in the following steps.

So what is going on here? I guess your mistake (imo, it isn't a mistake, but rather it is good that you try to understand things) here is that you are not incoporating the last step into your thoughts. In fact, if you had the state sequence RED,RED,GREEN, your result would be S1,S1,S1.

However, when you now add the next signal, BLUE, the algorithm takes into account that transitions S1->S3 (which is the preferred state for BLUE) are much more unlikely than S2->S3. Thus it favors S1,S1,S2,S3 instead of S1,S1,S1,S3, even though the latter would minimize the first three signals alone.

davidhigh
  • 14,652
  • 2
  • 44
  • 75
  • Thanks for the answer. That is the point that I can't understand. How is the S1->S3 is more unlikely than S2->S3? Did you find it based on the viterbi algorithm matrix? Could you please explain it? I have also another question how can you find the last probability(S1,S1,S1,S3 sequence )? – yns May 12 '14 at 13:27
  • I found it in the transition matrix: `P(S1->S3)=-1.6, P(S2->S3)=-0.7`. (--I have considered only your emission and transition matrix up to now.) It is due to this large difference that ..,S1,S2,S3 is chosen in favor of ..S1,S1,S3 (even though S1->S1 is similarly more probably than S1->S2). I suggest you to try the complete algorithm again with RED, GREEN, BLUE (as this is easier than an explanation in words). Further, I don't understand exactly what you mean by your second question. – davidhigh May 12 '14 at 14:13