DiscreteHMM Class Reference

A wrapper class for HMM functionals in discrete case. More...

Collaboration diagram for DiscreteHMM:
[legend]

List of all members.

Public Member Functions

void ComputeLogLikelihood (const ArrayList< Vector > &list_data_seq, ArrayList< double > *list_likelihood) const
 Compute the log-likelihood of a list of sequences.
double ComputeLogLikelihood (const Vector &data_seq) const
 Compute the log-likelihood of a sequence.
void ComputeViterbiStateSequence (const Vector &data_seq, Vector *state_seq) const
 Compute the most probable sequence (Viterbi).
void DecodeInit (const Vector &data_seq, Matrix *state_prob_mat, Matrix *forward_prob_mat, Matrix *backward_prob_mat, Vector *scale_vec) const
 A decode version that initialized the out matrices.
void DecodeOverwrite (const Vector &data_seq, Matrix *state_prob_mat, Matrix *forward_prob_mat, Matrix *backward_prob_mat, Vector *scale_vec) const
 Decode a sequence into probabilities of each state at each time step using scaled forward-backward algorithm.
const Matrix & emission () const
void EstimateModel (int numstate, int numsymbol, const Vector &data_seq, const Vector &state_seq)
void EstimateModel (const Vector &data_seq, const Vector &state_seq)
 Estimate the matrices by a data sequence and a state sequence Must be already initialized.
void GenerateSequence (int length, Vector *data_seq, Vector *state_seq) const
 Generate a random data sequence of a given length.
void Init (const Matrix &transmission, const Matrix &emission)
 Initializes from computed transmission and emission matrices.
void InitFromData (const ArrayList< Vector > &list_data_seq, int numstate)
 Initializes randomly using data as a guide.
void InitFromFile (const char *profile)
 Initializes by loading from a file.
void LoadProfile (const char *profile)
 Load from file, used when already initialized.
void SaveProfile (const char *profile) const
 Save matrices to file.
void setModel (const Matrix &transmission, const Matrix &emission)
 Setters used when already initialized.
void TrainBaumWelch (const ArrayList< Vector > &list_data_seq, int max_iteration, double tolerance)
 Train the model with a list of sequences, must be already initialized using Baum-Welch EM algorithm.
void TrainViterbi (const ArrayList< Vector > &list_data_seq, int max_iteration, double tolerance)
 Train the model with a list of sequences, must be already initialized using Viterbi algorithm to determine the state sequence of each sequence.
const Matrix & transmission () const
 Basic getters.

Static Public Member Functions

static void BackwardProcedure (const Vector &seq, const Matrix &trans, const Matrix &emis, const Vector &scales, Matrix *bs)
static double Decode (const Vector &seq, const Matrix &trans, const Matrix &emis, Matrix *pstates, Matrix *fs, Matrix *bs, Vector *scales)
static void EstimateInit (int numSymbols, int numStates, const Vector &seq, const Vector &states, Matrix *trans, Matrix *emis)
static void EstimateInit (const Vector &seq, const Vector &states, Matrix *trans, Matrix *emis)
 Estimate transition and emission probabilities from sequence and states.
static void ForwardProcedure (const Vector &seq, const Matrix &trans, const Matrix &emis, Vector *scales, Matrix *fs)
 Calculate posteriori probabilities of states at each steps Scaled Forward - Backward procedure seq: Vector of length L of emissions trans: Transition probabilities, size M x M emis: Emission probabilities, size M x N pstates: size M x L fs: scaled forward probabities, size M x L bs: scaled backward probabities, size M x L scales: scale factors, length L RETURN: log probabilities of sequence.
static void GenerateInit (int L, const Matrix &trans, const Matrix &emis, Vector *seq, Vector *states)
 Generating a sequence and states using transition and emission probabilities.
static void Train (const ArrayList< Vector > &seqs, Matrix *guessTR, Matrix *guessEM, int max_iter, double tol)
 Baum-Welch estimation of transition and emission probabilities.
static void TrainViterbi (const ArrayList< Vector > &seqs, Matrix *guessTR, Matrix *guessEM, int max_iter, double tol)
 Viterbi estimation of transition and emission probabilities.
static double ViterbiInit (int L, const Vector &seq, const Matrix &trans, const Matrix &emis, Vector *states)
static double ViterbiInit (const Vector &seq, const Matrix &trans, const Matrix &emis, Vector *states)
 Calculate the most probable states for a sequence Viterbi algorithm seq: Vector of length L of emissions trans: Transition probabilities, size M x M emis: Emission probabilities, size M x N states: Unitialized, will have length L RETURN: log probability of the most probable sequence.

Detailed Description

A wrapper class for HMM functionals in discrete case.

This class maintains transition probabilities and emission probabilities matrices and performs basic HMM functionals, more details below.

Definition at line 55 of file discreteHMM.h.


Member Function Documentation

void DiscreteHMM::ComputeLogLikelihood ( const ArrayList< Vector > &  list_data_seq,
ArrayList< double > *  list_likelihood 
) const
double DiscreteHMM::ComputeLogLikelihood ( const Vector data_seq  )  const

Compute the log-likelihood of a sequence.

Definition at line 137 of file discreteHMM.cc.

References ForwardProcedure(), GenVector< T >::Init(), and GenVector< T >::length().

void DiscreteHMM::ComputeViterbiStateSequence ( const Vector data_seq,
Vector state_seq 
) const

Compute the most probable sequence (Viterbi).

Definition at line 169 of file discreteHMM.cc.

References ViterbiInit().

void DiscreteHMM::DecodeInit ( const Vector data_seq,
Matrix *  state_prob_mat,
Matrix *  forward_prob_mat,
Matrix *  backward_prob_mat,
Vector scale_vec 
) const

A decode version that initialized the out matrices.

Definition at line 125 of file discreteHMM.cc.

References GenVector< T >::Init(), and GenVector< T >::length().

void DiscreteHMM::DecodeOverwrite ( const Vector data_seq,
Matrix *  state_prob_mat,
Matrix *  forward_prob_mat,
Matrix *  backward_prob_mat,
Vector scale_vec 
) const

Decode a sequence into probabilities of each state at each time step using scaled forward-backward algorithm.

Also return forward, backward probabilities and scale factors

Definition at line 121 of file discreteHMM.cc.

void DiscreteHMM::EstimateInit ( const Vector seq,
const Vector states,
Matrix *  trans,
Matrix *  emis 
) [static]

Estimate transition and emission probabilities from sequence and states.

Definition at line 225 of file discreteHMM.cc.

References GenVector< T >::length().

Referenced by EstimateModel(), and InitFromData().

void DiscreteHMM::EstimateModel ( const Vector data_seq,
const Vector state_seq 
)

Estimate the matrices by a data sequence and a state sequence Must be already initialized.

Definition at line 109 of file discreteHMM.cc.

References EstimateInit().

void DiscreteHMM::ForwardProcedure ( const Vector seq,
const Matrix &  trans,
const Matrix &  emis,
Vector scales,
Matrix *  fs 
) [static]

Calculate posteriori probabilities of states at each steps Scaled Forward - Backward procedure seq: Vector of length L of emissions trans: Transition probabilities, size M x M emis: Emission probabilities, size M x N pstates: size M x L fs: scaled forward probabities, size M x L bs: scaled backward probabities, size M x L scales: scale factors, length L RETURN: log probabilities of sequence.

Definition at line 281 of file discreteHMM.cc.

References GenVector< T >::get(), GenVector< T >::length(), and GenVector< T >::SetZero().

Referenced by ComputeLogLikelihood().

void DiscreteHMM::GenerateInit ( int  L,
const Matrix &  trans,
const Matrix &  emis,
Vector seq,
Vector states 
) [static]

Generating a sequence and states using transition and emission probabilities.

L: sequence length trans: Matrix M x M (M states) emis: Matrix M x N (N emissions) seq: uninitialized vector, will have length L states: uninitialized vector, will have length L

Definition at line 181 of file discreteHMM.cc.

References GenVector< T >::Copy(), and GenVector< T >::Init().

Referenced by GenerateSequence().

void DiscreteHMM::GenerateSequence ( int  length,
Vector data_seq,
Vector state_seq 
) const

Generate a random data sequence of a given length.

Definition at line 105 of file discreteHMM.cc.

References GenerateInit().

void DiscreteHMM::Init ( const Matrix &  transmission,
const Matrix &  emission 
)

Initializes from computed transmission and emission matrices.

Definition at line 53 of file discreteHMM.cc.

void DiscreteHMM::InitFromData ( const ArrayList< Vector > &  list_data_seq,
int  numstate 
)

Initializes randomly using data as a guide.

Definition at line 73 of file discreteHMM.cc.

References EstimateInit(), GenVector< T >::Init(), ArrayList< TElem >::length(), and ArrayList< TElem >::size().

void DiscreteHMM::InitFromFile ( const char *  profile  ) 

Initializes by loading from a file.

Definition at line 60 of file discreteHMM.cc.

References ArrayList< TElem >::size().

Referenced by LoadProfile().

void DiscreteHMM::LoadProfile ( const char *  profile  ) 

Load from file, used when already initialized.

Definition at line 88 of file discreteHMM.cc.

References InitFromFile().

void DiscreteHMM::SaveProfile ( const char *  profile  )  const

Save matrices to file.

Definition at line 94 of file discreteHMM.cc.

References TextWriter::Open().

void DiscreteHMM::setModel ( const Matrix &  transmission,
const Matrix &  emission 
)

Setters used when already initialized.

Definition at line 44 of file discreteHMM.cc.

void DiscreteHMM::Train ( const ArrayList< Vector > &  seqs,
Matrix *  guessTR,
Matrix *  guessEM,
int  max_iter,
double  tol 
) [static]

Baum-Welch estimation of transition and emission probabilities.

Definition at line 422 of file discreteHMM.cc.

References GenVector< T >::get(), GenVector< T >::Init(), GenMatrix< T >::Init(), ArrayList< TElem >::length(), and ArrayList< TElem >::size().

Referenced by TrainBaumWelch().

void DiscreteHMM::TrainBaumWelch ( const ArrayList< Vector > &  list_data_seq,
int  max_iteration,
double  tolerance 
)

Train the model with a list of sequences, must be already initialized using Baum-Welch EM algorithm.

Definition at line 173 of file discreteHMM.cc.

References Train().

void DiscreteHMM::TrainViterbi ( const ArrayList< Vector > &  seqs,
Matrix *  guessTR,
Matrix *  guessEM,
int  max_iter,
double  tol 
) [static]

Viterbi estimation of transition and emission probabilities.

Definition at line 495 of file discreteHMM.cc.

References GenMatrix< T >::Init(), ArrayList< TElem >::length(), ArrayList< TElem >::size(), and ViterbiInit().

void DiscreteHMM::TrainViterbi ( const ArrayList< Vector > &  list_data_seq,
int  max_iteration,
double  tolerance 
)

Train the model with a list of sequences, must be already initialized using Viterbi algorithm to determine the state sequence of each sequence.

Definition at line 177 of file discreteHMM.cc.

const Matrix& DiscreteHMM::transmission (  )  const [inline]

Basic getters.

Definition at line 71 of file discreteHMM.h.

double DiscreteHMM::ViterbiInit ( const Vector seq,
const Matrix &  trans,
const Matrix &  emis,
Vector states 
) [static]

Calculate the most probable states for a sequence Viterbi algorithm seq: Vector of length L of emissions trans: Transition probabilities, size M x M emis: Emission probabilities, size M x N states: Unitialized, will have length L RETURN: log probability of the most probable sequence.

Definition at line 357 of file discreteHMM.cc.

References GenVector< T >::length().

Referenced by ComputeViterbiStateSequence(), and TrainViterbi().


The documentation for this class was generated from the following files:
Generated on Mon Jan 24 12:04:40 2011 for FASTlib by  doxygen 1.6.3