Home Statistical Dictionary Forward-Backward Algorithm
Forward-Backward Algorithm
A dynamic programming procedure that computes the probability of a hidden Markov model being in each possible state at every time point, using the entire observed sequence, both what came before and what came after.
In Plain English
If you only look at observations up to the present, you can make a reasonable guess about a hidden Markov model's current hidden state, that's filtering. But the forward-backward algorithm does better: it uses the entire sequence, including observations that haven't happened yet relative to a given time point, to compute the best possible estimate of the hidden state at every point in the sequence, a step called smoothing. It works by combining two efficient sweeps through the data, a forward pass accumulating evidence from the past, and a backward pass accumulating evidence from the future, then combining the two at each time point.
Definition
The forward-backward algorithm computes the smoothed posterior distribution for a hidden Markov model, using the entire observed sequence of length . The forward pass recursively computes , the joint probability of the observations up to time and being in state at time , building up from to . The backward pass recursively computes , the probability of the remaining future observations given state at time , building up from back to . Combining both, , gives the exact smoothed state probability using all available information. Both the forward and backward recursions run in time (for hidden states and sequence length ), a dramatic improvement over the naive cost of summing over every possible hidden state sequence directly, and the forward pass alone also gives the total sequence likelihood , needed for the E-step of the Baum-Welch algorithm.
Formula
Notation
Properties
- The dynamic programming trick underlying both passes, reusing partial computations rather than recomputing sums from scratch, is exactly what turns an intractable exponential-time problem (summing over every possible length- hidden state sequence) into a polynomial-time one, the same core idea that makes the Viterbi algorithm efficient too.
- Forward probabilities alone answer the filtering question (state given only past and present observations) and the total-likelihood question, needed on their own in real-time applications, while the full forward-backward combination is needed specifically for smoothing and for the E-step of Baum-Welch parameter learning.
- This algorithm has close cousins across the broader state-space model family: the Kalman filter's forward pass (filtering) and the associated Kalman smoother (using a backward pass analogous to ) solve the exact same forward/backward estimation problem for linear-Gaussian, continuous-state models instead of discrete HMMs.
At a Glance