Изменения

Перейти к: навигация, поиск

Алгоритм "Вперед-Назад"

24 байта добавлено, 10:18, 15 марта 2018
Псевдокод
'''fun''' alpha(s: '''int''', t: '''int'''): '''int'''
'''if''' (s, t) '''in''' fwd '''return''' fwd[s, t] 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]
'''fun''' beta(s: '''int''', t: '''int'''): '''int'''
'''if''' (s, t) '''in''' bkw '''return''' bkw[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 '''for''' j '''in''' S chainProbability += alpha(j, 1) * beta(j, 1) '''for''' s '''in''' S '''for''' t '''in''' [1, T] probabilities[s, t] = (alpha(s, t) * beta(s, t)) / chainProbability
== См. также ==
Анонимный участник

Навигация