Sleipnir
Public Member Functions
Sleipnir::CHMM Class Reference

Extremely simple Hidden Markov Model (HMM) implementation allowing learning and generation from the model. More...

#include <hmm.h>

Inheritance diagram for Sleipnir::CHMM:
Sleipnir::CHMMImpl

Public Member Functions

void Open (size_t iDegree, const std::string &strAlphabet)
 Initializes an empty HMM of the requested degree over the given alphabet.
void Save (std::ostream &ostm) const
 Outputs a simple textual representation of the HMM.
bool Add (const std::string &strData)
 Updates the HMMs transition probabilities using the given string as training data.
std::string Get (size_t iLength) const
 Randomly generates the requested number of characters from the HMM's alphabet using its current transition probabilities.
void SetUniform ()
 Sets all transition probabilities in the HMM to uniform probabilities.

Detailed Description

Extremely simple Hidden Markov Model (HMM) implementation allowing learning and generation from the model.

Implements a simple HMM of arbitrary degree over a fixed alphabet of single characters. The HMM can be learned from input strings and, after training, can generate random sequences probabilistically from the model.

Definition at line 37 of file hmm.h.


Member Function Documentation

bool Sleipnir::CHMM::Add ( const std::string &  strData) [inline]

Updates the HMMs transition probabilities using the given string as training data.

Parameters:
strDataString of characters from which transition probabilities are updated.
Returns:
True if the transitions were updated successfully; false otherwise.
Remarks:
Characters not in the HMM's alphabet are ignored.
See also:
Get

Definition at line 93 of file hmm.h.

References Sleipnir::CFullMatrix< tType >::Get().

std::string Sleipnir::CHMM::Get ( size_t  iLength) const [inline]

Randomly generates the requested number of characters from the HMM's alphabet using its current transition probabilities.

Parameters:
iLengthNumber of characters to randomly generate.
Returns:
The requested number of characters randomly generated using the HMM's current transition probabilities.
See also:
Add

Definition at line 120 of file hmm.h.

References Sleipnir::CFullMatrix< tType >::Get(), Sleipnir::CFullMatrix< tType >::GetColumns(), and Sleipnir::CFullMatrix< tType >::GetRows().

void Sleipnir::CHMM::Open ( size_t  iDegree,
const std::string &  strAlphabet 
) [inline]

Initializes an empty HMM of the requested degree over the given alphabet.

Parameters:
iDegreeDegree of the HMM.
strAlphabetAlphabet of characters encoded by the HMM.
Remarks:
iDegree must be greater than zero; strAlphabet must be nonempty.

Definition at line 52 of file hmm.h.

References Sleipnir::CFullMatrix< tType >::Clear(), and Sleipnir::CFullMatrix< tType >::Initialize().

void Sleipnir::CHMM::Save ( std::ostream &  ostm) const [inline]

Outputs a simple textual representation of the HMM.

Parameters:
ostmStream to which the HMM is saved.

Definition at line 66 of file hmm.h.

References Sleipnir::CFullMatrix< tType >::Get(), Sleipnir::CFullMatrix< tType >::GetColumns(), and Sleipnir::CFullMatrix< tType >::GetRows().


The documentation for this class was generated from the following file: