Content deleted Content added
→Extensions: ...and moved later HMM reference to first occurence |
→Pseudocode: Reformatting |
||
Line 62:
Restated in a succinct near-[[Python (programming language)|Python]]:
<math>trellis \leftarrow matrix(length(S), length(O))</math> To hold probability of each state given each observation
'''for''' s '''in''' <math>range(length(S))</math>: Determine each hidden state's probability at time 0…
'''for'''
'''for''' s '''in''' <math>range(length(S))</math>:▼
▲ trellis[s, 0] ← Π[s] * Em[s, O[0]]
<math>trellis[s, o] \leftarrow trellis[k, o-1] * Tm[k, s] * Em[s, o]</math>
▲ '''for''' s in range(length(S)):
<math>best\_path \leftarrow list()</math>
▲ ''k'' ← argmax(''k'' in trellis[''k'', o-1] * Tm[''k'', s] * Em[s, o])
<math>k \leftarrow \arg\max(k\
▲ pointers[s, o] ← ''k''
'''return''' ''best_path''▼
▲ '''for''' o in range(length(O)-1, -1, -1): # Backtrack from last observation.
▲ best_path.insert(0, S[''k'']) # Insert previous state on most likely path
▲ '''return''' best_path
;Explanation:
|