public class HMM<O> extends java.lang.Object implements SequenceLabeler<O>
In a regular Markov model, the state is directly visible to the observer, and therefore the state transition probabilities are the only parameters. In a hidden Markov model, the state is not directly visible, but output, dependent on the state, is visible. Each state has a probability distribution over the possible output tokens. Therefore the sequence of tokens generated by an HMM gives some information about the sequence of states.
Constructor and Description 

HMM(double[] pi,
double[][] a,
double[][] b)
Constructor.

HMM(double[] pi,
double[][] a,
double[][] b,
O[] symbols)
Constructor.

HMM(int[][] observations,
int[][] labels)
Learn an HMM from labeled observation sequences by maximum likelihood
estimation.

HMM(O[][] observations,
int[][] labels)
Learn an HMM from labeled observation sequences by maximum likelihood
estimation.

Modifier and Type  Method and Description 

double[] 
getInitialStateProbabilities()
Returns the initial state probabilities.

double[][] 
getStateTransitionProbabilities()
Returns the state transition probabilities.

double[][] 
getSymbolEmissionProbabilities()
Returns the symbol emission probabilities.

HMM<O> 
learn(int[][] observations,
int iterations)
With this HMM as the initial model, learn an HMM by the BaumWelch
algorithm.

HMM<O> 
learn(O[][] observations,
int iterations)
With this HMM as the initial model, learn an HMM by the BaumWelch
algorithm.

double 
logp(int[] o)
Returns the logarithm probability of an observation sequence given this
HMM.

double 
logp(int[] o,
int[] s)
Returns the log joint probability of an observation sequence along a
state sequence given this HMM.

double 
logp(O[] o)
Returns the logarithm probability of an observation sequence given this
HMM.

double 
logp(O[] o,
int[] s)
Returns the log joint probability of an observation sequence along a
state sequence given this HMM.

int 
numStates()
Returns the number of states.

int 
numSymbols()
Returns the number of emission symbols.

double 
p(int[] o)
Returns the probability of an observation sequence given this HMM.

double 
p(int[] o,
int[] s)
Returns the joint probability of an observation sequence along a state
sequence given this HMM.

double 
p(O[] o)
Returns the probability of an observation sequence given this HMM.

double 
p(O[] o,
int[] s)
Returns the joint probability of an observation sequence along a state
sequence given this HMM.

int[] 
predict(int[] o)
Returns the most likely state sequence given the observation sequence by
the Viterbi algorithm, which maximizes the probability of
P(I  O, HMM) . 
int[] 
predict(O[] o)
Returns the most likely state sequence given the observation sequence by
the Viterbi algorithm, which maximizes the probability of
P(I  O, HMM) . 
java.lang.String 
toString() 
public HMM(double[] pi, double[][] a, double[][] b)
pi
 the initial state probabilities.a
 the state transition probabilities, of which a[i][j] is P(s_j 
s_i);b
 the symbol emission probabilities, of which b[i][j] is P(o_j 
s_i).public HMM(double[] pi, double[][] a, double[][] b, O[] symbols)
pi
 the initial state probabilities.a
 the state transition probabilities, of which a[i][j] is P(s_j 
s_i);b
 the symbol emission probabilities, of which b[i][j] is P(o_j 
s_i).symbols
 the list of emission symbols.public HMM(int[][] observations, int[][] labels)
observations
 the observation sequences, of which symbols take
values in [0, n), where n is the number of unique symbols.labels
 the state labels of observations, of which states take
values in [0, p), where p is the number of hidden states.public HMM(O[][] observations, int[][] labels)
observations
 the observation sequences.labels
 the state labels of observations, of which states take
values in [0, p), where p is the number of hidden states.public int numStates()
public int numSymbols()
public double[] getInitialStateProbabilities()
public double[][] getStateTransitionProbabilities()
public double[][] getSymbolEmissionProbabilities()
public double p(int[] o, int[] s)
o
 an observation sequence.s
 a state sequence.public double logp(int[] o, int[] s)
o
 an observation sequence.s
 a state sequence.public double p(int[] o)
o
 an observation sequence.public double logp(int[] o)
o
 an observation sequence.public int[] predict(int[] o)
P(I  O, HMM)
. In the calculation, we may get ties. In this
case, one of them is chosen randomly.o
 an observation sequence.public HMM<O> learn(O[][] observations, int iterations)
observations
 the observation sequences on which the learning is
based. Each sequence must have a length higher or equal to 2.iterations
 the number of iterations to execute.public HMM<O> learn(int[][] observations, int iterations)
observations
 the observation sequences on which the learning is
based. Each sequence must have a length higher or equal to 2.iterations
 the number of iterations to execute.public java.lang.String toString()
toString
in class java.lang.Object
public double p(O[] o, int[] s)
o
 an observation sequence.s
 a state sequence.public double logp(O[] o, int[] s)
o
 an observation sequence.s
 a state sequence.public double p(O[] o)
o
 an observation sequence.public double logp(O[] o)
o
 an observation sequence.public int[] predict(O[] o)
P(I  O, HMM)
. In the calculation, we may get ties. In this
case, one of them is chosen randomly.predict
in interface SequenceLabeler<O>
o
 an observation sequence.