Viterbi algorithm
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 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. P_{t,s} = \begin{cases} \pi_s \cdot b_{s,o_t} & \text{if } t=0, \\ \max_{r \in S} \left(P_{t-1,r} \cdot a_{r,s} \cdot b_{s,o_t} \right) & \text{if } t>0. \end{cases} The formula for Q_{t,s} is identical for t>0 , except that \max is replaced with \arg\max , and Q_{0,s} = 0 . The Viterbi path can be found by selecting the maximum of P at the final timestep, and following Q in reverse. prob[0][s] = init[s] * emit[s][obs[0 for t = 1 to T - 1 inclusive do // t = 0 has been dealt with already for each state s in states do for each state r in states do new_prob ← prob[t - 1][r] * trans[r][s] * emit[s][obs[t if new_prob > prob[t][s] then prob[t][s] ← new_prob prev[t][s] ← r path ← empty array of length T path[T - 1] ← the state s with maximum prob[T - 1][s] for t = T - 2 to 0 inclusive do path[t] ← prev[t + 1][path[t + 1 return path end The time complexity of the algorithm is O(T\times\left|{S}\right|^2) . If it is known which state transitions have non-zero probability, an improved bound can be found by iterating over only those r which link to s in the inner loop. Then using amortized analysis one can show that the complexity is O(T\times(\left|{S}\right| + \left|{E}\right|)) , where E is the number of edges in the graph, i.e. the number of non-zero entries in the transition matrix. init = {"Healthy": 0.6, "Fever": 0.4} trans = { "Healthy": {"Healthy": 0.7, "Fever": 0.3}, "Fever": {"Healthy": 0.4, "Fever": 0.6}, } emit = { "Healthy": {"normal": 0.5, "cold": 0.4, "dizzy": 0.1}, "Fever": {"normal": 0.1, "cold": 0.3, "dizzy": 0.6}, } In this code, init represents the doctor's belief about how likely the patient is to be healthy initially. Note that the particular probability distribution used here is not the equilibrium one, which would be {'Healthy': 0.57, 'Fever': 0.43} according to the transition probabilities. The transition probabilities trans represent the change of health condition in the underlying Markov chain. In this example, a patient who is healthy today has only a 30% chance of having a fever tomorrow. The emission probabilities emit represent how likely each possible observation (normal, cold, or dizzy) is, given the underlying condition (healthy or fever). A patient who is healthy has a 50% chance of feeling normal; one who has a fever has a 60% chance of feeling dizzy. A particular patient visits three days in a row, and reports feeling normal on the first day, cold on the second day, and dizzy on the third day. Firstly, the probabilities of being healthy or having a fever on the first day are calculated. The probability that a patient will be healthy on the first day and report feeling normal is 0.6 \times 0.5 = 0.3 . Similarly, the probability that a patient will have a fever on the first day and report feeling normal is 0.4 \times 0.1 = 0.04 . The probabilities for each of the following days can be calculated from the previous day directly. For example, the highest chance of being healthy on the second day and reporting to be cold, following reporting being normal on the first day, is the maximum of 0.3 \times 0.7 \times 0.4 = 0.084 and 0.04 \times 0.4 \times 0.4 = 0.0064 . This suggests it is more likely that the patient was healthy for both of those days, rather than having a fever and recovering. The rest of the probabilities are summarised in the following table: From the table, it can be seen that the patient most likely had a fever on the third day. Furthermore, there exists a sequence of states ending on "fever", of which the probability of producing the given observations is 0.01512. This sequence is precisely (healthy, healthy, fever), which can be found be tracing back which states were used when calculating the maxima (which happens to be the best guess from each day but will not always be). In other words, given the observed activities, the patient was most likely to have been healthy on the first day and on the second day (despite feeling cold that day), and only to have contracted a fever on the third day. The operation of Viterbi's algorithm can be visualized by means of a trellis diagram. The Viterbi path is essentially the shortest path through this trellis.
References
- ^ Xavier Anguera et al., "Speaker Diarization: A Review of Recent Research" Archived 2016-05-12 at the Wayback Machine , retrieved 19. August 2010, IEEE TASLP Wikipedia revision 1375500441, retrieved 2026-11-19 · 1795042800.0
- ^ A fast maximum-likelihood decoder for convolutional codes (PDF) . Vehicular Technology Conference . December 2002. pp. 371– 375. doi : 10.1109/VETECF.2002.1040367 . Wikipedia revision 1375500441, retrieved 2026-11-19 · 1795042800.0
- ^ 29 Apr 2005, G. David Forney Jr: The Viterbi Algorithm: A Personal History Wikipedia revision 1375500441, retrieved 2026-11-19 · 1795042800.0
- ^ Schmid, Helmut (2004). Efficient parsing of highly ambiguous context-free grammars with bit vectors (PDF) . Proc. 20th Int'l Conf. on Computational Linguistics (COLING). doi : 10.3115/1220355.1220379 . Wikipedia revision 1375500441, retrieved 2026-11-19 · 1795042800.0
- ^ Klein, Dan; Manning, Christopher D. (2003). A* parsing: fast exact Viterbi parse selection (PDF) . Proc. 2003 Conf. of the North American Chapter of the Association for Computational Linguistics on Human Language Technology (NAACL). pp. 40– 47. doi : 10.3115/1073445.1073461 . Wikipedia revision 1375500441, retrieved 2026-11-19 · 1795042800.0
- ^ Stanke, M.; Keller, O.; Gunduz, I.; Hayes, A.; Waack, S.; Morgenstern, B. (2006). "AUGUSTUS: Ab initio prediction of alternative transcripts" . Nucleic Acids Research . 34 (Web Server issue): W435– W439. doi : 10.1093/nar/gkl200 . PMC 1538822 . PMID 16845043 . Wikipedia revision 1375500441, retrieved 2026-11-19 · 1795042800.0
- ^ Quach, T.; Farooq, M. (1994). "Maximum Likelihood Track Formation with the Viterbi Algorithm". Proceedings of 33rd IEEE Conference on Decision and Control . Vol. 1. pp. 271– 276. doi : 10.1109/CDC.1994.410918 . {{ cite conference }} : CS1 maint: multiple names: authors list ( link ) Wikipedia revision 1375500441, retrieved 2026-11-19 · 1795042800.0
- ^ Xing E, slide 11. Wikipedia revision 1375500441, retrieved 2026-11-19 · 1795042800.0
- ^ Qi Wang; Lei Wei; Rodney A. Kennedy (2002). "Iterative Viterbi Decoding, Trellis Shaping, and Multilevel Structure for High-Rate Parity-Concatenated TCM". IEEE Transactions on Communications . 50 : 48– 55. doi : 10.1109/26.975743 . Wikipedia revision 1375500441, retrieved 2026-11-19 · 1795042800.0
- ^ a b Daniel Jurafsky; James H. Martin. Speech and Language Processing . Pearson Education International. p. 246. Wikipedia revision 1375500441, retrieved 2026-11-19 · 1795042800.0
Cite this
"Viterbi algorithm". 1789697527. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1375500441