08.10.2016 Views

Foundations of Data Science

2dLYwbK

2dLYwbK

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

for t = 1 to T<br />

Prob(O 0 O 1 · · · O t , i) = ∑ j<br />

Prob(O 0 O 1 · · · O t−1 , j)a ij p(O t+1 , i)<br />

Example: What is the probability <strong>of</strong> the sequence hhht by the HMM in the above two<br />

state example?<br />

t = 3<br />

3<br />

t = 2<br />

1<br />

t = 1<br />

1<br />

1 1<br />

+ 5 3 1<br />

= 19<br />

32 2 2 72 4 2 384<br />

1 1<br />

+ 1 3 1<br />

= 3<br />

8 2 2 6 4 2 32<br />

1 1<br />

= 1<br />

2 2 2 8<br />

t = 0<br />

1<br />

2<br />

0<br />

q<br />

3 1 1<br />

+ 5 1 1<br />

= 37<br />

32 2 3 72 4 3 64×27<br />

1 1 2<br />

+ 1 1 2<br />

= 5<br />

8 2 3 6 4 3 72<br />

1 1 2<br />

= 1<br />

2 2 3 6<br />

For t = 0, the q entry is 1/2 since the probability <strong>of</strong> being in state q is one and the probability<br />

<strong>of</strong> outputting heads is 1 . The entry for p is zero since the probability <strong>of</strong> starting in<br />

2<br />

state p is zero. For t = 1, the q entry is 1 since for t = 0 the q entry is 1 and in state q<br />

8 2<br />

the HMM goes to state q with probability 1 and outputs heads with probability 1. The<br />

2 2<br />

p entry is 1 since for t = 0 the q entry is 1 and in state q the HMM goes to state p with<br />

6 2<br />

probability 1 and outputs heads with probability 2 3<br />

. For t = 2, the q entry is which<br />

2 3 32<br />

consists <strong>of</strong> two terms. The first term is the probability <strong>of</strong> ending in state q at t = 1 times<br />

the probability <strong>of</strong> staying in q and outputting h. The second is the probability <strong>of</strong> ending<br />

in state p at t = 1 times the probability <strong>of</strong> going from state p to state q and outputting h.<br />

From the table, the probability <strong>of</strong> producing the sequence hhht is 19<br />

384 + 37<br />

1728 = 0.0709.<br />

p<br />

The most likely sequence <strong>of</strong> states - the Viterbi algorithm<br />

Given a HMM and an observation O = O 0 O 1 · · · O T , what is the most likely sequence <strong>of</strong><br />

states? The solution is given by the Viterbi algorithm, which is a slight modification to the<br />

dynamic programming algorithm just given for determining the probability <strong>of</strong> an output<br />

sequence. For t = 0, 1, 2, . . . , T and for each state i, calculate the probability <strong>of</strong> the most<br />

likely sequence <strong>of</strong> states to produce the output O 0 O 1 O 2 · · · O t ending in state i. For each<br />

value <strong>of</strong> t, calculate the most likely sequence <strong>of</strong> states by selecting over all states j the most<br />

likely sequence producing O 0 O 1 O 2 · · · O t and ending in state i consisting <strong>of</strong> the most likely<br />

sequence producing O 0 O 1 O 2 · · · O t−1 ending in state j followed by the transition from j<br />

to i producing O t . Note that in the previous example, we added the probabilities <strong>of</strong> each<br />

possibility together. Now we take the maximum and also record where the maximum<br />

came from. The time complexity is O(n 2 T ) and the space complexity is O(nT ). The<br />

space complexity bound is argued as follows. In calculating the probability <strong>of</strong> the most<br />

likely sequence <strong>of</strong> states that produces O 0 O 1 . . . O t ending in state i, we remember the<br />

305

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!