Hidden Markov Model example:

The model has two states, with uniform initial distribution. The transition probabilities are:

  to State 1 to State 2
From State 1 1/3 2/3
From State 2 3/4 1/4

The output alphabet is {+, 0, -}, with probabilities:

  State 1 State 2
P(+) 1/4 1/3
P(0) 1/2 1/3
P(-) 1/4 1/3

The object is to find the probability of the output sequence + - 0 using the forward algorithm and then again using the backward algorithm.

The forward algorithm starts by multiplying the initial probabilities (1/2) by the probabilities of + (1/4 and 1/3):

State 1 1/2 * 1/4 = 1/8 1/8 * 1/3 * 1/4 + 1/6 * 3/4 * 1/4 = 1/24 1/24 * 1/3 * 1/2 + 1/24 * 3/4 * 1/2 = 13/576
State 2 1/2 * 1/3 = 1/6 1/8 * 2/3 * 1/3 + 1/6 * 1/4 * 1/3 = 1/24 1/24 * 2/3 * 1/3 + 1/24 * 1/4 * 1/3 = 11/864

The total probability of + - 0 is the sum of these. The common denominator is 1728, so 13/576 + 11/864 = 61/1728

The backward algorithm starts with ones on the right, and moves to the left:
State 1 7/18 * 1/3 * 1/4 + 11/24 * 2/3 * 1/3 = 29/216 1 * 1/3 * 1/2 + 1 * 2/3 * 1/3 = 7/18 1
State 2 7/18 * 3/4 * 1/4 + 11/24 * 1/4 * 1/3 = 1/9 1 * 3/4* 1/2 + 1 * 1/4 * 1/3 = 11/24 1

In this case, we can't just add these together, we must multiply by the initial probabilities and the probability of producing a + in the appropriate state:

29/216 * 1/2 * 1/4 + 1/9 * 1/2 * 1/3 = 61/1728