# GroupHMM Algorithms Algorithms on HmmGraph objects.

## Grouped Function Overview

• `TCargo backwardAlgorithm(hmm, seq);`
Given a Hidden Markov Model hmm, the backward algorithm computes the probability of the sequence seq.
• `TCargo forwardAlgorithm(hmm, seq);`
Given a Hidden Markov Model hmm, the forward algorithm computes the probability of the sequence seq.
• `void generateSequence(hmm, seq, states, numSeq, maxLen);`
Generates random state and alphabet sequence of a given HMM.
• `TCargo viterbiAlgorithm(path, hmm, seq);`
Implements the Viterbi algorithm for Hidden Markov Models.

## Grouped Functions Detail

### `TCargo backwardAlgorithm(hmm, seq);`

Defined in
<seqan/graph_algorithms.h>
Given a Hidden Markov Model hmm, the backward algorithm computes the probability of the sequence seq.

#### Parameters

 `hmm` The HmmGraph with the HMM to use. Input sequence to use in the backward algorithm.

#### Returns

`TCargo` The probability of the sequence seq. TProbability is the type parameter TCargo of the type of hmm.

See the Wikipedia article on the Forward-backward algorithm for an introduction to the algorithm itself.

### `TCargo forwardAlgorithm(hmm, seq);`

Defined in
<seqan/graph_algorithms.h>
Given a Hidden Markov Model hmm, the forward algorithm computes the probability of the sequence seq.

#### Parameters

 `hmm` The HmmGraph with the HMM to use. Input sequence to use in the forward algorithm.

#### Returns

`TProbability` The probability of the sequence seq. TProbability is the type parameter TCargo of the type of hmm.

#### Remarks

See the Wikipedia article on the Forward algorithm for an introduction to the algorithm itself.

### `void generateSequence(hmm, seq, states, numSeq, maxLen);`

Defined in
<seqan/graph_algorithms.h>
Generates random state and alphabet sequence of a given HMM.

#### Parameters

 `seq` A StringSet of alphabet sequences. A ContainerConcept object of state sequences. The HmmGraph to use. The number of sequences to generate. The maximum length of the sequences. The sequences might be shorter if the ends tate is reached before maxLen.

#### Remarks

Because of silent states, generated alphabet and state sequences might have different lengths.

### `TCargo viterbiAlgorithm(path, hmm, seq);`

Defined in
<seqan/graph_algorithms.h>
Implements the Viterbi algorithm for Hidden Markov Models.

#### Parameters

 `path` The state path; String of vertex descriptors. The HmmGraph to use. Input sequence.

#### Returns

`TCargo` Probability of the path, the type parameter TCargo from type of hmm.

The Viterbi algorithm computes the most likely sequence of hidden states of the Hidden Markov Model hmm given the sequence seq using dynamic programming. The result is the most likely sequence of hidden states and returned in path.

#### Remarks

See the Wikipedia article on the Viterbi algorithm for an introduction to the algorithm itself.