Backward algorithm 2026-10-20
The backward algorithm computes suffix likelihoods in a Hidden Markov model. With , its recurrence is . Together with the forward algorithm, it gives posterior state probabilities proportional to . The terminal condition must include any explicit End-state transition.
Daniel Jurafsky 2026-11-05
Daniel Jurafsky coauthored Speech and Language Processing by Daniel Jurafsky and James H. Martin. The text presents mathematical models and computational procedures for natural language processing, including sequence models that connect linguistic observations to latent states.[ref]
In a Hidden Markov model, the current hidden state determines the emission distribution and the next-state probabilities. This separation permits the forward algorithm to compute an observation sequence's likelihood by summing locally over preceding states. The assumptions make inference tractable, while their suitability for a particular language task remains a modelling question. A tractable calculation does not by itself establish that the model captures every dependency in real language.
Forward algorithm 2026-10-20
The forward algorithm computes sequence likelihoods by summing over all hidden paths through a Hidden Markov model. For emitting states, obeys . It reuses partial sums rather than enumerating exponentially many state sequences. Silent states require additional transitions without consuming an observation. Scaling or log-sum-exp prevents floating-point underflow.
Hidden Markov model Created 2026-09-28 Updated 2026-11-05
James H. Martin 2026-11-05
James H. Martin coauthored Speech and Language Processing by Daniel Jurafsky and James H. Martin with Daniel Jurafsky. Its treatment connects natural language processing to explicit probabilistic models and algorithms. The hidden-state appendix gives the initial, transition and emission distributions of a Hidden Markov model and derives the forward algorithm.[ref]
Speech and Language Processing by Daniel Jurafsky and James H. Martin. AppendixA.2–A.3, August2026 draft
For a sequence of observations, the forward calculation sums over possible hidden-state histories instead of selecting only one best history. Sharing partial calculations avoids enumerating every full state sequence. The resulting efficiency comes from the model's conditional-independence assumptions, not from treating arbitrary sequences as independent.
The sequence has five characters, while the four match states account for four compulsory emissions. Consequently exactly one insertion state emission is needed. An insertion at would have to emit T, which has probability zero there. The only nonzero hidden path is thereforeMultiply its transition probabilities and emission probabilities, including the probability of exiting immediately and bypassing :Normally the forward algorithm sums over all compatible paths. Here all other paths have probability zero, so this single path gives the full sequence probability.
Use a uniform independent DNA background, so each nucleotide has probability . Conditional on length five, its sequence probability is . The requested score, often called log-odds in sequence analysis, is a log-likelihood ratio against this background:Using natural logarithms instead gives . Identically distributed independent positions do not, by themselves, require equal base frequencies. If the intended background instead has specified frequencies , the general answer isThe numerical value above uses the conventional equal-frequency random DNA model.
Taking a logarithm only after multiplying probabilities does not prevent floating-point underflow: the product may already have rounded to zero, and its logarithm is then . Accumulate logarithms before forming tiny products; where alternative paths must be added, use log-sum-exp in the forward algorithm or rescale its intermediate probabilities.
Let be the hidden state. With the usual convention and , the Markov property and the conditional independence of emissions factor the joint probability asThe requested state-path probability after observing the complete data is the corresponding conditional probability:Here the forward algorithm and backward algorithm give the same normalizer at any interior time,There is no extra factor : it is already included in . If an unconditioned joint probability with the observations is intended, it is the numerator alone. Summing the boxed expression over all gives one.