

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
java.lang.Object org.jscience.computing.hmm.HMM
public class HMM
Implements a hidden Markov model and its algorithms including ForwardBackward, Viterbi, Kmeans, BaumWelch, and KullbackLeibler distance measure.
Field Summary  

double[][] 
a
transition probabilities 
double[][] 
b
emission probabilities 
int 
dimensions
number of dimensions 
int 
numStates
number of states 
double[] 
pi
initial state probabilities 
int 
sigmaSize
size of output vocabulary 
double[][] 
V
output vocabulary 
Constructor Summary  

HMM(int numStates,
int sigmaSize)
Class constructor. 

HMM(int numStates,
int sigmaSize,
int dimensions)
Class constructor. 
Method Summary  

double[][] 
backwardProc(int[] o)
Calculation of Backward variables b(i,t) for state i at time t for sequence o with the current HMM parameters. 
void 
baumWelch(int[] o,
int steps)
BaumWelch algorithm for hidden Markov models. 
int[] 
convert(double[][] sequence,
int D,
int T)
Converts a sequence of actually values into their corresponding indices based on the vocabulary of this HMM. 
double[][] 
forwardProc(int[] o)
Calculation of Forward variables f(i,t) for state i at time t for sequence o with the current HMM parameters. 
double 
gamma(int i,
int t,
int[] o,
double[][] fwd,
double[][] bwd)
Calculation of gamma_t(i), which is the probability P(i_t = s_i  o, hmm), that is, the probability of being in state i at time given observation sequence o and this HMM. 
double 
hmmDistance(HMM hmm2)
Calculates the distance between two hidden Markov models using the KullbackLeibler distance measure. 
static HMM 
kmeansLearner(java.lang.String data,
int N,
int steps)
Kmeans algorithm for hidden Markov models. 
static HMM 
load(java.lang.String filename)
Loads an HMM from a file. 
int[] 
observationGeneration(int length)
Generates an observation sequence of a given length using this HMM. 
void 
print()
Prints all the parameters of this HMM. 
double[][] 
viterbi(int[] o)
Viterbi algorithm for hidden Markov models. 
void 
write(java.lang.String filename)
Writes this HMM to a file. 
double 
xi(int t,
int i,
int j,
int[] o,
double[][] fwd,
double[][] bwd)
Calculation of xi_t(i, j), which is the probability P(i_t = s_i, i_t+1 = s_j  o, hmm), that is, the probability of being in state i at time t and state j at time t+1 given observation sequence o and this HMM. 
Methods inherited from class java.lang.Object 

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 
Field Detail 

public int numStates
public int sigmaSize
public int dimensions
public double[][] V
public double[] pi
public double[][] a
public double[][] b
Constructor Detail 

public HMM(int numStates, int sigmaSize)
numStates
 number of statessigmaSize
 size of output vocabularypublic HMM(int numStates, int sigmaSize, int dimensions)
numStates
 number of statessigmaSize
 size of output vocabularydimensions
 number of dimensionsMethod Detail 

public void baumWelch(int[] o, int steps)
o
 the observation sequencesteps
 the number of iterations performedpublic double[][] forwardProc(int[] o)
o
 the observation sequence
public double[][] backwardProc(int[] o)
o
 the observation sequence
public double xi(int t, int i, int j, int[] o, double[][] fwd, double[][] bwd)
t
 the timei
 the number of state s_ij
 the number of state s_jo
 the observation sequencefwd
 the Forward variables for obwd
 the Backward variables for o
public double gamma(int i, int t, int[] o, double[][] fwd, double[][] bwd)
i
 the number of state s_it
 the timeo
 the observation sequencefwd
 the Forward variables for obwd
 the Backward variables for o
public double[][] viterbi(int[] o)
o
 the observation sequence
public static HMM kmeansLearner(java.lang.String data, int N, int steps) throws java.io.IOException
data
 the filename of training data fileN
 the number of statessteps
 the number of iterations
java.io.IOException
 If training data file is invalidpublic double hmmDistance(HMM hmm2)
hmm2
 the hidden Markov model that will be compared against this
HMM
public int[] observationGeneration(int length)
length
 the length of the observation sequence to be generated
public int[] convert(double[][] sequence, int D, int T)
sequence
 the observation sequence (actual values)D
 the number of dimensions of sequenceT
 the length of sequence
public void print()
public static HMM load(java.lang.String filename) throws java.io.IOException
filename
 name of file to read the HMM from
java.io.IOException
 if the file format is incorrectpublic void write(java.lang.String filename) throws java.io.IOException
filename
 name of file to write this HMM to
java.io.IOException
 if a problem occurred while writing to the file


PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 