Content deleted Content added
Cleared up the variable names |
No edit summary |
||
Line 328:
<source lang="python">
def fwd_bkw(observations, states, start_prob, trans_prob, emm_prob, end_st):
# forward part of the algorithm▼
fwd = []
f_prev = {}
▲ # forward part of the algorithm
for i, observation_i in enumerate(observations):
f_curr = {}
Line 347:
p_fwd = sum(f_curr[k] * trans_prob[k][end_st] for k in states)
# backward part of the algorithm▼
bkw = []
b_prev = {}
▲ # backward part of the algorithm
for i, observation_i_plus in enumerate(reversed(observations[1:]+(None,))):
b_curr = {}
|