Package QSTK :: Package qstklearn :: Module hmm
[hide private]
[frames] | no frames]

Module hmm

source code

This package includes code for representing and learning HMM's.

Most of the code in this package was derived from the descriptions provided in 'A Tutorial on Hidden Markov Models and Selected Applications in Speach Recognition' by Lawence Rabiner.

Conventions: The keyword argument elem_size will be passed in when creating numpy array objects.

Classes [hide private]
  HMMLearner
A class for modeling and learning HMMs.
Functions [hide private]
 
calcalpha(stateprior, transition, emission, observations, numstates, elem_size=<type 'numpy.float128'>)
Calculates 'alpha' the forward variable.
source code
 
forwardbackward(stateprior, transition, emission, observations, numstates, elem_size=<type 'numpy.float128'>)
Calculates the probability of a sequence given the HMM.
source code
 
calcbeta(transition, emission, observations, numstates, elem_size=<type 'numpy.float128'>)
Calculates 'beta' the backward variable.
source code
 
calcxi(stateprior, transition, emission, observations, numstates, alpha=None, beta=None, elem_size=<type 'numpy.float128'>)
Calculates 'xi', a joint probability from the 'alpha' and 'beta' variables.
source code
 
calcgamma(xi, seqlen, numstates, elem_size=<type 'numpy.float128'>)
Calculates 'gamma' from xi.
source code
 
baumwelchstep(stateprior, transition, emission, observations, numstates, numsym, elem_size=<type 'numpy.float128'>)
Given an HMM model and a sequence of observations, computes the Baum-Welch update to the parameters using gamma and xi.
source code
Variables [hide private]
  __package__ = 'QSTK.qstklearn'
Function Details [hide private]

calcalpha(stateprior, transition, emission, observations, numstates, elem_size=<type 'numpy.float128'>)

source code 

Calculates 'alpha' the forward variable.

The alpha variable is a numpy array indexed by time, then state (TxN). alpha[t][i] = the probability of being in state 'i' after observing the first t symbols.

calcbeta(transition, emission, observations, numstates, elem_size=<type 'numpy.float128'>)

source code 

Calculates 'beta' the backward variable.

The beta variable is a numpy array indexed by time, then state (TxN). beta[t][i] = the probability of being in state 'i' and then observing the symbols from t+1 to the end (T).

calcxi(stateprior, transition, emission, observations, numstates, alpha=None, beta=None, elem_size=<type 'numpy.float128'>)

source code 

Calculates 'xi', a joint probability from the 'alpha' and 'beta' variables.

The xi variable is a numpy array indexed by time, state, and state (TxNxN). xi[t][i][j] = the probability of being in state 'i' at time 't', and 'j' at time 't+1' given the entire observation sequence.

calcgamma(xi, seqlen, numstates, elem_size=<type 'numpy.float128'>)

source code 

Calculates 'gamma' from xi.

Gamma is a (TxN) numpy array, where gamma[t][i] = the probability of being in state 'i' at time 't' given the full observation sequence.