CS 640 Bioinformatics HMM Viterbi Algorithm example
Given the following HMM:
1. N = 3, states S1, S2, S3
2. M=4 symbols in alphabet {a, c, t, g}
3. Initial probability distribution vector π = {.25, .5, .25}
4. Transition probability matrix τ, where τij=probability of transition from state i to state j
S1
.25
.25
.5
S1
S2
S3
S2
.5
.25
.5
S3
.25
.5
0
5. Emission probabilities e where ei(c)=probability that state i emits character c
a
c
t
g
S1
1
0
0
0
S2 .25 .5
0
.25
S3 .25 .25 .25 .25
Viterbi recurrence relations:
1(i) = iei(O1)
t+1(i) = ei (O t+1) max ( t(j) * τji )
Initialization:
Iteration:
1<= j <= N
C
S1
¼ *0=0
S2
½*½=¼
S3
¼ * ¼ = 1/16
C
0 * max{…} = 0
0*½
½ * max{ ¼* ¼ } = 1/32
1
/16 * ½
0*¼
¼ * max{ ¼* ½ } = 1/32
1
/16 * 0
T
0 * max{…} = 0
0 * max{…} = 0
0*¼
1
¼ * max{ 1/32 * ½ } = /256
1
/32 * 0
A traceback of the above array yields this best path sequence of states through the HMM
to produce the output string:
S2 S2 S3
© Copyright 2026 Paperzz