Description Usage Arguments Value Author(s) References See Also Examples

The Viterbi algorithm computes the most likely sequence of states given an HMM and an observation sequence.

1 2 |

`hmm` |
Object of class |

`obs` |
A vector containing the observation sequence. |

`names` |
Logical indicating whether state names should be returned.
If |

A list with components

`stateSeq` |
Most likely state sequence. |

`logProb` |
The probability of |

`matrix` |
The dynamic programming matrix. |

Peter Humburg

Viterbi, A. J. 1967
Error bounds for convolutional codes and an assymptotically optimal decoding algorithm.
*IEEE Transactions on Information Theory*, **13**, 2600–269.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ```
## create two state HMM with t distributions
state.names <- c("one","two")
transition <- c(0.1, 0.02)
location <- c(1, 2)
scale <- c(1, 1)
df <- c(4, 6)
model <- getHMM(list(a=transition, mu=location, sigma=scale, nu=df),
state.names)
## obtain observation sequence from model
obs <- sampleSeq(model, 100, return.states=TRUE)
## compute most likely state sequence for obs
vit.res <- viterbi(model, obs$observation)
## how well did we do?
sum(vit.res$stateSeq == obs$states)/length(vit.res$stateSeq)
``` |

```
[1] 0.85
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.