GClasses
GClasses::GHiddenMarkovModel Class Reference

#include <GHiddenMarkovModel.h>

Public Member Functions

 GHiddenMarkovModel (int stateCount, int symbolCount)
 
 ~GHiddenMarkovModel ()
 
void baumWelch (std::vector< int * > &sequences, std::vector< int > &lengths, int maxPasses=0x7fffffff)
 Uses expectation maximization to refine the model based on a training set of observation sequences. (You should have already set prior values for the initial, transition and symbol probabilites before you call this method.) More...
 
double forwardAlgorithm (const int *pObservations, int len)
 Calculates the log probability that the specified observation sequence would occur with this model. More...
 
double * initialStateProbabilities ()
 Returns the current vector of initial state probabilities. More...
 
double * symbolProbabilities ()
 Returns the current vector of symbol probabilities, such that pSymbolProbabilities[stateCount * i + j] is the probability of observing symbol j when in state i. More...
 
double * transitionProbabilities ()
 Returns the current vector of transition probabilities, such that pTransitionProbabilities[stateCount * i + j] is the probability of transitioning from state i to state j. More...
 
double viterbi (int *pMostLikelyStates, const int *pObservations, int len)
 Finds the most likely state sequence to explain the specified observation sequence, and also returns the log probability of that state sequence given the observation sequence. More...
 

Static Public Member Functions

static void test ()
 Performs unit tests for this class. Throws an exception if there is a failure. More...
 

Protected Member Functions

void backwardAlgorithm (const int *pObservations, int len)
 
void baumWelchAddSequence (const int *pObservations, int len)
 
void baumWelchBeginPass ()
 
void baumWelchBeginTraining (int maxLen)
 
double baumWelchEndPass ()
 
void baumWelchEndTraining ()
 

Protected Attributes

int m_maxLen
 
double * m_pInitialStateProbabilities
 
double * m_pSymbolProbabilities
 
double * m_pTrainingBuffer
 
double * m_pTransitionProbabilities
 
int m_stateCount
 
int m_symbolCount
 

Constructor & Destructor Documentation

GClasses::GHiddenMarkovModel::GHiddenMarkovModel ( int  stateCount,
int  symbolCount 
)
GClasses::GHiddenMarkovModel::~GHiddenMarkovModel ( )

Member Function Documentation

void GClasses::GHiddenMarkovModel::backwardAlgorithm ( const int *  pObservations,
int  len 
)
protected
void GClasses::GHiddenMarkovModel::baumWelch ( std::vector< int * > &  sequences,
std::vector< int > &  lengths,
int  maxPasses = 0x7fffffff 
)

Uses expectation maximization to refine the model based on a training set of observation sequences. (You should have already set prior values for the initial, transition and symbol probabilites before you call this method.)

void GClasses::GHiddenMarkovModel::baumWelchAddSequence ( const int *  pObservations,
int  len 
)
protected
void GClasses::GHiddenMarkovModel::baumWelchBeginPass ( )
protected
void GClasses::GHiddenMarkovModel::baumWelchBeginTraining ( int  maxLen)
protected
double GClasses::GHiddenMarkovModel::baumWelchEndPass ( )
protected
void GClasses::GHiddenMarkovModel::baumWelchEndTraining ( )
protected
double GClasses::GHiddenMarkovModel::forwardAlgorithm ( const int *  pObservations,
int  len 
)

Calculates the log probability that the specified observation sequence would occur with this model.

double* GClasses::GHiddenMarkovModel::initialStateProbabilities ( )
inline

Returns the current vector of initial state probabilities.

double* GClasses::GHiddenMarkovModel::symbolProbabilities ( )
inline

Returns the current vector of symbol probabilities, such that pSymbolProbabilities[stateCount * i + j] is the probability of observing symbol j when in state i.

static void GClasses::GHiddenMarkovModel::test ( )
static

Performs unit tests for this class. Throws an exception if there is a failure.

double* GClasses::GHiddenMarkovModel::transitionProbabilities ( )
inline

Returns the current vector of transition probabilities, such that pTransitionProbabilities[stateCount * i + j] is the probability of transitioning from state i to state j.

double GClasses::GHiddenMarkovModel::viterbi ( int *  pMostLikelyStates,
const int *  pObservations,
int  len 
)

Finds the most likely state sequence to explain the specified observation sequence, and also returns the log probability of that state sequence given the observation sequence.

Member Data Documentation

int GClasses::GHiddenMarkovModel::m_maxLen
protected
double* GClasses::GHiddenMarkovModel::m_pInitialStateProbabilities
protected
double* GClasses::GHiddenMarkovModel::m_pSymbolProbabilities
protected
double* GClasses::GHiddenMarkovModel::m_pTrainingBuffer
protected
double* GClasses::GHiddenMarkovModel::m_pTransitionProbabilities
protected
int GClasses::GHiddenMarkovModel::m_stateCount
protected
int GClasses::GHiddenMarkovModel::m_symbolCount
protected