When you dictate a message to your phone, your words arrive at the microphone as a stream of noisy acoustic signals. The phone doesn't hear words — it hears frequencies. Yet in milliseconds it reconstructs the most likely sentence you said. How?
The answer is the Viterbi algorithm, published by Andrew Viterbi in 1967 for decoding error-correcting codes sent over noisy radio channels. The idea is deceptively simple: the world has hidden states (the words you spoke, the genes in a genome, the market regime a stock is in), and you only see noisy observations (acoustic features, DNA bases, closing prices). The two are linked by a probabilistic model called a Hidden Markov Model (HMM).
The brute-force approach — try every possible sequence of hidden states and pick the most likely one — takes time exponential in the length of the sequence. With 10 possible states and a sequence of 100 steps, that is candidates. Hopeless.
Viterbi's insight was that the problem has optimal substructure: the most likely path to any state at step t depends only on the most likely path to each state at step t − 1, not on the full history. That single observation turns the exponential blowup into an dynamic programming sweep — where T is the sequence length and N is the number of hidden states. The result is the unique maximum-probability path, found exactly in polynomial time.
This is not an approximation. It is a provably optimal, efficient algorithm — one of the cleanest victories of dynamic programming in all of computer science.
Comments
Loading comments...