442
правки
Изменения
→Псевдокод
f = 0
'''for''' j '''in''' S
f += alpha(j, t - 1) * transitionProbability[j][, s] f *= emitProbability[s][, observations[t]]
fwd[s, t] = f
'''return''' fwd[s, t]
b = 0
'''for''' j '''in''' S
b += beta(j, t + 1) * transitionProbability[s][, j] * emitProbability[j][, O[t + 1]]
bkw[s, t] = b
'''return''' bkw[s, t]
'''fun''' forward_backward():
'''for''' s '''in''' S
fwd[s, 1] = emitProbability[s][, observations[1]] * П[s]
bkw[s, observations.length - 1] = 1
chainProbability = 0