ArticleslgStudy

computer science

Viterbi algorithm

Viterbi algorithm is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Viterbi algorithm rather than just read about it. In short: The Viterbi algorithm is a dynamic programming algorithm that finds the most likely sequence of hidden events that would explain a sequence of observed events. The result of the algorithm is often called the Viterbi path.

Viterbi algorithm — main illustration
Viterbi algorithm — illustration

Key takeaways

  • Viterbi algorithm belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Viterbi algorithm to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Viterbi algorithm from memory before moving on to harder problems.

Reference excerpt

The Viterbi algorithm is a dynamic programming algorithm that finds the most likely sequence of hidden events that would explain a sequence of observed events. The result of the algorithm is often called the Viterbi path. It is most commonly used with hidden Markov models (HMMs). For example, if a doctor observes a patient's symptoms over several days (the observed events), the Viterbi algorithm could determine the most probable sequence of underlying health conditions (the hidden events) that caused those symptoms. The algorithm has found universal application in decoding the convolutional codes used in both CDMA and GSM digital cellular, dial-up modems, satellite, deep-space communications, and 802.11 wireless LANs. It is also commonly used in speech recognition, speech synthesis, diarization, keyword spotting, computational linguistics, and bioinformatics. For instance, in speech-to-text (speech recognition), the acoustic signal is the observed sequence, and a string of text is the "hidden cause" of that signal. The Viterbi algorithm finds the most likely string of text given the acoustic signal.

History The Viterbi algorithm is named after Andrew Viterbi, who proposed it in 1967 as a decoding algorithm for convolutional codes over noisy digital communication links. It has, however, a history of multiple invention, with at least seven independent discoveries, including those by Viterbi, Needleman and Wunsch, and Wagner and Fischer. It was introduced to natural language processing as a method of part-of-speech tagging as early as 1987. Viterbi path and Viterbi algorithm have become standard terms for the application of dynamic programming algorithms to maximization problems involving probabilities. For example, in statistical parsing a dynamic programming algorithm can be used to discover the single most likely context-free derivation (parse) of a string, which is commonly called the "Viterbi parse". Another application is in target tracking, where the track is computed that assigns a maximum likelihood to a sequence of observations.

Algorithm Given a hidden Markov model with a set of hidden states S {\displaystyle S} , a set of possible emissions (observations) M, and a sequence of T {\displaystyle T} observations o 0 , o 1 , … , o T − 1 {\displaystyle o_{0},o_{1},\dots ,o_{T-1}} , the Viterbi algorithm finds the most likely sequence of hidden states that could have produced those observations. At each time step t {\displaystyle t} , the algorithm solves the subproblem where only the observations up to o t {\displaystyle o_{t}} are considered. Two matrices of size T × | S | {\displaystyle T\times \left|{S}\right|} are constructed:

P t , s {\displaystyle P_{t,s}} contains the maximum probability of ending up at state s {\displaystyle s} at observation t {\displaystyle t} , out of all possible sequences of states leading up to it.

Q t , s {\displaystyle Q_{t,s}} tracks the previous state that was used before s {\displaystyle s} in this maximum probability state sequence. Let π s {\displaystyle \pi _{s}} and a r , s {\displaystyle a_{r,s}} be the initial and transition probabilities respectively, and let b s , o {\displaystyle b_{s,o}} be the probability of observing o {\displaystyle o} at state s {\displaystyle s} . Then the values of P {\displaystyle P} are given by the recurrence relation

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Viterbi algorithm

Start with the simplest possible case. Write down what Viterbi algorithm claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Viterbi algorithm before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Viterbi algorithm ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Viterbi algorithm

In research
Viterbi algorithm appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Viterbi algorithm in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Viterbi algorithm is common in secondary-school and first-year university syllabi. It links to neighbouring topics Dynamic programming, Error detection and correction, Markov models, so understanding it makes those chapters shorter.
In everyday life
Look for Viterbi algorithm outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Viterbi algorithm” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Viterbi algorithm in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Viterbi algorithm means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Viterbi algorithm out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Viterbi algorithm in simple terms?

The Viterbi algorithm is a dynamic programming algorithm that finds the most likely sequence of hidden events that would explain a sequence of observed events. The result of the algorithm is often called the Viterbi path.

Why does Viterbi algorithm matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Viterbi algorithm?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Viterbi algorithm.

Tags

  • Dynamic programming
  • Error detection and correction
  • Markov models

Keep exploring