Forward-backward algorithm

From Wikipedia, the free encyclopedia

Jump to: navigation, search

In computer science, the forward-backward algorithm is a dynamic programming algorithm for computing the probability of a particular observation sequence. It operates in the context of hidden Markov models.

Contents

1 Overview

2 Formal description

3 Example

4 Performance

5 Pseudocode

6 See also

7 References

8 External links

[edit] Overview

The algorithm comprises three steps:

computing forward probabilities

computing backward probabilities

computing smoothed values

The forward and backward steps are often called "forward message pass" and "backward message pass". The wording originates from the way the algorithm processes the given observation sequence. First the algorithm moves forward starting with the first observation in the sequence and going to the last, and then returning back to the first. At each single observation in the sequence probabilities to be used for calculations at the next observation are computed. During the backward pass the algorithm simultaneously performs the smoothing step. This step allows the algorithm to take into account any past observations of output for computing more accurate results.

[edit] Formal description

The following description takes as its base matrices of probability values rather than probability distributions. We transform the probability distributions related to a given hidden Markov model into matrix notation as follows. The transition probabilities of a given random variable Xt representing all possible states in the hidden Markov model will be represented by the matrix where the row index, i, will represent the start state and the column index, j, represents the target state. For example, in the example below would be defined as:

Similarly, we will represent the probabilities of a new state, given some observed states as evidence, in an observation matrix where each diagonal entry contains the probability of a new state given the particular observed state at t as evidence. Note that t indicates a particular observation in the observation sequence. All other entries in the matrix will be zero. For example, in the example below the first observed evidence (t=1) is "umbrella". Therefore would be defined as:

This allows a very elegant description of how to compute the next forward probability. Let the set of forward probabilities be stored in yet another matrix . Where 1:t+1 indicates that the computed probabilities are depending on all forward probabilities from 1 to t+1 including the current one which we will describe with . Hence, is equal to the multiplication of the transposed transformation matrix with the current forward probabilities and the observation matrix for the next evidence observation. Finally the resulting matrix requires normalization, i.e. the resulting values in the matrix are divided by the sum of all values in the matrix. The normalization factor is described with α. Therefore the resulting forward computation is described by the following general formula:

We can describe the backward computation that starts at the end of the sequence in a similar manner. Let the end of the sequence be described by the index k, starting at 0. Therefore running from k down to t=0 and calculating each backward probability can be described by the following formula:

Note that we use the non-transposed matrix of and that the order of the terms has changed. Also note that as a final product we have not a usual matrix multiplication, but a point product. This operation multiplies each value in one matrix with the corresponding value of the other. Finally note that the description in Russel & Norvig 2003 pp. 550 excludes the point product, though the procedure is required earlier.

The third and final step involves the computation of smoothed probabilities . These are the point product of the backward and forward probabilities for each t. Therefore the formular is defined as:

The example in the following section will show numerically the calculation of these matrices.

[edit] Example

This example takes as its basis the umbrella world in Russel & Norvig 2003 pp. 540. The example uses a longer observation sequence {umbrella, umbrella, no umbrella, umbrella, umbrella} than the example described in the book. Assume the probabilities for rain given an umbrella observation are 90% if an umbrella is observed and 20% if no umbrella is observed. Furthermore, assume that the probability of rain in t+1 given the weather in t to be a 70% chance that the weather will stay the same, and a 30% chance that the weather will change. The following matrices can be extracted from the umbrella world given the above observations:

Note that differs from the others because of the "no umbrella" observation. Also note that and are equal because they are symmetrical. Before we can start to compute forward messages we need to describe two special values, the first forward probability and the k+2 backward probability. The first forward probability at t=0 is defined by the prior of the random variable. The k+2 backward probability is defined by the "true" matrix. Therefore it follows:

Now we will first iterate through all t and compute the forward probabilities. The following matrices appear in the same order as described in the forward formula above. Some calculations may be less accurate due to the limited numbers of decimals used in this example.

Now that we have defined the forward probabilities, we continue to compute the backward probabilities. Again the matrices appear in the order as in the backward formula above.

=> Someone should recompute the final results because the formula for the backward message was previously wrong and was corrected above and in the following equations, but the result was not recomputed.

Finally we will compute the smoothed probability values. The ordering of the matrices follows the smoothed values formula above.

[edit] Performance

The brute-force procedure for the solution of this problem is the generation of all possible sequences of observed events and hidden states with their probabilities using the two transition matrices. The joint probability of two sequences, given the model, is calculated by multiplying the corresponding probabilities. The brute force procedure has time complexity , where T is the length of sequences and N is the number of symbols in the state alphabet. This is intractable for realistic problems, as the number of possible hidden node sequences typically is extremely high. However, the forward-backward algorithm has time complexity . Several enhancements are known to the general forward-backward algorithm which allow for computations to take place in constant space. In addition, as t grows, algorithms have been developed to compute efficiently through online smoothing such as the fixed-lag smoothing (FLS) algorithm Russel & Norvig 2003 pp. 552.

[edit] Pseudocode

ForwardBackward(guessState, sequenceIndex):
if sequenceIndex is past the end of the sequence, return 1
if (guessState, sequenceIndex) has been seen before, return saved result
result = 0
for each neighboring state n:
result = result + (transition probability from guessState to n given observation element at sequenceIndex)*ForwardBackward(n, sequenceIndex+1)
save result for (guessState, sequenceIndex)
return result

[edit] See also

Baum-Welch algorithm

Hidden Markov model

Viterbi algorithm

BCJR algorithm

[edit] References

Lawrence R. Rabiner, A Tutorial on Hidden Markov Models and Selected Applications in Speech Recognition. Proceedings of the IEEE, 77 (2), p. 257–286, February 1989.

Rabiner L. R., Juang B. H. (January 1986). "An introduction to hidden Markov models". IEEE ASSP Magazine: 4–15.

Charniak Eugene (1993). Statistical Language Learning. MIT Press. ISDN 978-0-262-53141-2.

Russel S., Norvig P. (2003). Artificial Intelligence A Modern Approach 2nd Edition. Pearson Education. ISBN 0-13-080302-2.

[edit] External links

An Interactive Spreadsheet for Teaching the Forward-Backward Algorithm (spreadsheet and article with step-by-step walk-through)

Tutorial of Hidden Markov Models including the forward-backward algorithm

Collection of AI algorithms implemented in Java (including HMM and the forward-backward algorithm)

This computer science-related article is a stub. You can help Wikipedia by expanding it.

Retrieved from "http://en.wikipedia.org/wiki/Forward-backward_algorithm"

Categories: Computer science stubs | Dynamic programming | Error detection and correction | Machine learning

Views

Article

Discussion

Edit this page

History

Personal tools

Log in / create account

Navigation

Main page

Contents

Featured content

Current events

Random article

Search

Interaction

About Wikipedia

Community portal

Recent changes

Contact Wikipedia

Donate to Wikipedia

Help

Toolbox

What links here

Related changes

Upload file

Special pages

Printable version

Permanent link

Cite this page

Languages

Español

Deutsch

This page was last modified on 11 February 2009, at 23:44.

All text is available under the terms of the GNU Free Documentation License. (See Copyrights for details.)
Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a U.S. registered 501(c)(3) tax-deductible nonprofit charity.

Privacy policy

About Wikipedia

Disclaimers