GClasses

GClasses::GHiddenMarkovModel Class Reference

#include <GHiddenMarkovModel.h>

List of all members.

Public Member Functions

 GHiddenMarkovModel (int stateCount, int symbolCount)
 ~GHiddenMarkovModel ()
double * initialStateProbabilities ()
 Returns the current vector of initial state probabilities.
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.
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.
double forwardAlgorithm (const int *pObservations, int len)
 Calculates the log probability that the specified observation sequence would occur with this model.
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.
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.)

Static Public Member Functions

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

Protected Member Functions

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

Protected Attributes

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

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