org.wiigee.logic
Class HMM

java.lang.Object
  extended by org.wiigee.logic.HMM
Direct Known Subclasses:
XHMM

public class HMM
extends java.lang.Object

This is a Hidden Markov Model implementation which internally provides the basic algorithms for training and recognition (forward and backward algorithm). Since a regular Hidden Markov Model doesn't provide a possibility to train multiple sequences, this implementation has been optimized for this purposes using some state-of-the-art technologies described in several papers.


Field Summary
protected  double[][] a
          The state change probability to switch from state A to state B: a[stateA][stateB]
protected  double[][] b
          The probability to emit symbol S in state A: b[stateA][symbolS]
protected  int numObservations
          The number of observations
protected  int numStates
          The number of states
protected  double[] pi
          The initial probabilities for each state: p[state]
 
Constructor Summary
HMM(int numStates, int numObservations)
          Initialize the Hidden Markov Model in a left-to-right version.
 
Method Summary
protected  double[][] backwardProc(int[] o)
          Backward algorithm.
protected  double[][] forwardProc(int[] o)
          Traditional Forward Algorithm.
 double[][] getA()
           
 double[][] getB()
           
 double[] getPi()
           
 double getProbability(int[] o)
          Returns the probability that a observation sequence O belongs to this Hidden Markov Model without using the bayes classifier.
 void print()
          Prints everything about this model, including all values.
 void setA(double[][] a)
           
 void setB(double[][] b)
           
 void setPi(double[] pi)
           
 void train(java.util.Vector<int[]> trainsequence)
          Trains the Hidden Markov Model with multiple sequences.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

numStates

protected int numStates
The number of states


numObservations

protected int numObservations
The number of observations


pi

protected double[] pi
The initial probabilities for each state: p[state]


a

protected double[][] a
The state change probability to switch from state A to state B: a[stateA][stateB]


b

protected double[][] b
The probability to emit symbol S in state A: b[stateA][symbolS]

Constructor Detail

HMM

public HMM(int numStates,
           int numObservations)
Initialize the Hidden Markov Model in a left-to-right version.

Parameters:
numStates - Number of states
numObservations - Number of observations
Method Detail

train

public void train(java.util.Vector<int[]> trainsequence)
Trains the Hidden Markov Model with multiple sequences. This method is normally not known to basic hidden markov models, because they usually use the Baum-Welch-Algorithm. This method is NOT the traditional Baum-Welch-Algorithm. If you want to know in detail how it works please consider my Individuelles Projekt paper on the wiigee Homepage. Also there exist some english literature on the world wide web. Try to search for some papers by Rabiner or have a look at Vesa-Matti Mäntylä - "Discrete Hidden Markov Models with application to isolated user-dependent hand gesture recognition".


forwardProc

protected double[][] forwardProc(int[] o)
Traditional Forward Algorithm.

Parameters:
o - the observationsequence O
Returns:
Array[State][Time]

getProbability

public double getProbability(int[] o)
Returns the probability that a observation sequence O belongs to this Hidden Markov Model without using the bayes classifier. Internally the well known forward algorithm is used.

Parameters:
o - observation sequence
Returns:
probability that sequence o belongs to this hmm

backwardProc

protected double[][] backwardProc(int[] o)
Backward algorithm.

Parameters:
o - observation sequence o
Returns:
Array[State][Time]

print

public void print()
Prints everything about this model, including all values. For debug purposes or if you want to comprehend what happend to the model.


getPi

public double[] getPi()

setPi

public void setPi(double[] pi)

getA

public double[][] getA()

setA

public void setA(double[][] a)

getB

public double[][] getB()

setB

public void setB(double[][] b)