# viterbi: Calculate Most Likely State Sequence Using the Viterbi... In tileHMM: Hidden Markov Models for ChIP-on-Chip Analysis

## Description

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

## Usage

 ```1 2``` ```## S4 method for signature 'hmm' viterbi(hmm, obs, names=TRUE) ```

## Arguments

 `hmm` Object of class `hmm`. `obs` A vector containing the observation sequence. `names` Logical indicating whether state names should be returned. If `TRUE` (the default) the returned sequence consists of state names, otherwise the state index is returned instead.

## Value

A list with components

 `stateSeq` Most likely state sequence. `logProb` The probability of `stateSeq` given `hmm` and `obs`. `matrix` The dynamic programming matrix.

Peter Humburg

## References

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

## See Also

`viterbiTraining`

## Examples

 ``` 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) ```

### Example output

```[1] 0.85
```

tileHMM documentation built on May 30, 2017, 3:41 a.m.