

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
java.lang.Object gov.sandia.cognition.util.AbstractCloneableSerializable gov.sandia.cognition.learning.algorithm.hmm.MarkovChain gov.sandia.cognition.learning.algorithm.hmm.HiddenMarkovModel<ObservationType>
ObservationType
 Type of Observations handled by the HMM.@PublicationReference(author="Lawrence R. Rabiner", title="A tutorial on hidden Markov models and selected applications in speech recognition", type=Journal, year=1989, publication="Proceedings of the IEEE", pages={257,286}, url="http://www.cs.ubc.ca/~murphyk/Bayes/rabiner.pdf", notes="Rabiner\'s transition matrix is transposed from mine.") public class HiddenMarkovModel<ObservationType>
A discretestate Hidden Markov Model (HMM) with either continuous or discrete observations.
Field Summary  

protected Collection<? extends ComputableDistribution<ObservationType>> 
emissionFunctions
The PDFs that emit symbols from each state. 
Fields inherited from class gov.sandia.cognition.learning.algorithm.hmm.MarkovChain 

DEFAULT_NUM_STATES, initialProbability, transitionProbability 
Constructor Summary  

HiddenMarkovModel()
Default constructor. 

HiddenMarkovModel(int numStates)
Creates a new instance of ContinuousDensityHiddenMarkovModel 

HiddenMarkovModel(Vector initialProbability,
Matrix transitionProbability,
Collection<? extends ComputableDistribution<ObservationType>> emissionFunctions)
Creates a new instance of ContinuousDensityHiddenMarkovModel 
Method Summary  

HiddenMarkovModel<ObservationType> 
clone()
This makes public the clone method on the Object class and
removes the exception that it throws. 

protected ArrayList<WeightedValue<Vector>> 
computeBackwardProbabilities(ArrayList<Vector> b,
ArrayList<WeightedValue<Vector>> alphas)
Computes the backwardprobabilities for the given observation likelihoods and the weights from the alphas. 

protected WeightedValue<Vector> 
computeBackwardProbabilities(Vector beta,
Vector b,
double weight)
Computes the backward probability recursion. 

protected ArrayList<WeightedValue<Vector>> 
computeForwardProbabilities(ArrayList<Vector> b,
boolean normalize)
Computes the forward probabilities for the given observation likelihood sequence. 

protected WeightedValue<Vector> 
computeForwardProbabilities(Vector alpha,
Vector b,
boolean normalize)
Computes the recursive solution to the forward probabilities of the HMM. 

protected double 
computeMultipleObservationLogLikelihood(Collection<? extends Collection<? extends ObservationType>> sequences)
Computes the loglikelihood of the observation sequences, given the current HMM's parameterization. 

protected ArrayList<Vector> 
computeObservationLikelihoods(Collection<? extends ObservationType> observations)
Computes the conditionally independent likelihoods for each state given the observation sequence. 

Vector 
computeObservationLikelihoods(ObservationType observation)
Computes the conditionally independent likelihoods for each state given the observation. 

protected void 
computeObservationLikelihoods(ObservationType observation,
Vector b)
Computes the conditionally independent likelihoods for each state given the observation. 

double 
computeObservationLogLikelihood(Collection<? extends ObservationType> observations)
Computes the loglikelihood of the observation sequence, given the current HMM's parameterization. 

double 
computeObservationLogLikelihood(Collection<? extends ObservationType> observations,
Collection<Integer> states)
Computes the loglikelihood that the given observation sequence was generated by the given sequence of state indices. 

protected ArrayList<Vector> 
computeStateObservationLikelihood(ArrayList<WeightedValue<Vector>> alphas,
ArrayList<WeightedValue<Vector>> betas,
double scaleFactor)
Computes the probabilities of the various states over time given the observation sequence. 

protected static Vector 
computeStateObservationLikelihood(Vector alpha,
Vector beta,
double scaleFactor)
Computes the probability of the various states at a time instance given the observation sequence. 

protected Matrix 
computeTransitions(ArrayList<WeightedValue<Vector>> alphas,
ArrayList<WeightedValue<Vector>> betas,
ArrayList<Vector> b)
Computes the stochastic transitionprobability matrix from the given probabilities. 

protected static Matrix 
computeTransitions(Vector alphan,
Vector betanp1,
Vector bnp1)
Computes the stochastic transitionprobability matrix from the given probabilities. 

protected Pair<Vector,int[]> 
computeViterbiRecursion(Vector delta,
Vector bn)
Computes the Viterbi recursion for a given "delta" and "b" 

static

createRandom(Collection<? extends ProbabilityFunction<ObservationType>> distributions,
Random random)
Creates a Hidden Markov Model with the given probability function for each state, but sampling the columns of the transition matrix and the initial probability distributions from a diffuse Dirichlet. 

static

createRandom(int numStates,
BatchLearner<Collection<? extends WeightedValue<? extends ObservationType>>,? extends ComputableDistribution<ObservationType>> learner,
Collection<? extends ObservationType> data,
Random random)
Creates a Hidden Markov Model with the same PMF/PDF for each state, but sampling the columns of the transition matrix and the initial probability distributions from a diffuse Dirichlet. 

static

createRandom(int numStates,
ComputableDistribution<ObservationType> distribution,
Random random)
Creates a Hidden Markov Model with the same PMF/PDF for each state, but sampling the columns of the transition matrix and the initial probability distributions from a diffuse Dirichlet. 

protected WeightedValue<Integer> 
findMostLikelyState(int destinationState,
Vector delta)
Finds the mostlikely next state given the previous "delta" in the Viterbi algorithm. 

Collection<? extends ComputableDistribution<ObservationType>> 
getEmissionFunctions()
Getter for emissionFunctions 

ObservationType 
sample(Random random)
Draws a single random sample from the distribution. 

ArrayList<ObservationType> 
sample(Random random,
int numSamples)
Draws multiple random samples from the distribution. 

void 
setEmissionFunctions(Collection<? extends ComputableDistribution<ObservationType>> emissionFunctions)
Setter for emissionFunctions. 

ArrayList<Vector> 
stateBeliefs(Collection<? extends ObservationType> observations)
Computes the probability distribution over all states for each observation. 

String 
toString()


ArrayList<Integer> 
viterbi(Collection<? extends ObservationType> observations)
Viterbi algorithm for decoding the mostlikely sequence of states from the HMMs underlying Markov chain for a given observation sequence. 
Methods inherited from class gov.sandia.cognition.learning.algorithm.hmm.MarkovChain 

createUniformInitialProbability, createUniformTransitionProbability, getFutureStateDistribution, getInitialProbability, getNumStates, getSteadyStateDistribution, getTransitionProbability, normalize, normalizeTransitionMatrix, normalizeTransitionMatrix, setInitialProbability, setTransitionProbability 
Methods inherited from class java.lang.Object 

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

protected Collection<? extends ComputableDistribution<ObservationType>> emissionFunctions
Constructor Detail 

public HiddenMarkovModel()
public HiddenMarkovModel(int numStates)
numStates
 Number of states in the HMM.public HiddenMarkovModel(Vector initialProbability, Matrix transitionProbability, Collection<? extends ComputableDistribution<ObservationType>> emissionFunctions)
initialProbability
 Initial probability Vector over the states. Each entry must be
nonnegative and the Vector must sum to 1.transitionProbability
 Transition probability matrix. The entry (i,j) is the probability
of transition from state "j" to state "i". As a corollary, all
entries in the Matrix must be nonnegative and the
columns of the Matrix must sum to 1.emissionFunctions
 The PDFs that emit symbols from each state.Method Detail 

public static <ObservationType> HiddenMarkovModel<ObservationType> createRandom(int numStates, BatchLearner<Collection<? extends WeightedValue<? extends ObservationType>>,? extends ComputableDistribution<ObservationType>> learner, Collection<? extends ObservationType> data, Random random)
ObservationType
 Type of observations to generate.numStates
 Number of states to createlearner
 Learner to create the distributions for each statedata
 Data from which to make the distributionrandom
 Random number generator
public static <ObservationType> HiddenMarkovModel<ObservationType> createRandom(int numStates, ComputableDistribution<ObservationType> distribution, Random random)
ObservationType
 Type of observations to generate.numStates
 Number of states to createdistribution
 Distribution from which we will assign to each state.random
 Random number generator
public static <ObservationType> HiddenMarkovModel<ObservationType> createRandom(Collection<? extends ProbabilityFunction<ObservationType>> distributions, Random random)
ObservationType
 Type of observations to generate.distributions
 The distribution for each state. The size of the collection is the
number of states to create.random
 Random number generator
public HiddenMarkovModel<ObservationType> clone()
AbstractCloneableSerializable
Object
class and
removes the exception that it throws. Its default behavior is to
automatically create a clone of the exact type of object that the
clone is called on and to copy all primitives but to keep all references,
which means it is a shallow copy.
Extensions of this class may want to override this method (but call
super.clone()
to implement a "smart copy". That is, to target
the most common use case for creating a copy of the object. Because of
the default behavior being a shallow copy, extending classes only need
to handle fields that need to have a deeper copy (or those that need to
be reset). Some of the methods in ObjectUtil
may be helpful in
implementing a custom clone method.
Note: The contract of this method is that you must use
super.clone()
as the basis for your implementation.
clone
in interface CloneableSerializable
clone
in class MarkovChain
public double computeObservationLogLikelihood(Collection<? extends ObservationType> observations)
observations
 Observations to consider.
protected double computeMultipleObservationLogLikelihood(Collection<? extends Collection<? extends ObservationType>> sequences)
sequences
 Observations sequences to consider
public double computeObservationLogLikelihood(Collection<? extends ObservationType> observations, Collection<Integer> states)
observations
 Observations to consider.states
 Indices of states hypothesized to have generated the observation
sequence.
public ObservationType sample(Random random)
Distribution
sample
in interface Distribution<ObservationType>
random
 Randomnumber generator to use in order to generate random numbers.
public ArrayList<ObservationType> sample(Random random, int numSamples)
Distribution
sample
in interface Distribution<ObservationType>
random
 Randomnumber generator to use in order to generate random numbers.numSamples
 Number of samples to draw from the distribution.
public Collection<? extends ComputableDistribution<ObservationType>> getEmissionFunctions()
public void setEmissionFunctions(Collection<? extends ComputableDistribution<ObservationType>> emissionFunctions)
emissionFunctions
 The PDFs that emit symbols from each state.protected WeightedValue<Vector> computeForwardProbabilities(Vector alpha, Vector b, boolean normalize)
alpha
 Previous alpha value.b
 Current observationemission likelihood.normalize
 True to normalize the alphas, false to leave them unnormalized.
protected ArrayList<WeightedValue<Vector>> computeForwardProbabilities(ArrayList<Vector> b, boolean normalize)
b
 Observation likelihood sequence.normalize
 True to normalize the alphas, false to leave them unnormalized.
public Vector computeObservationLikelihoods(ObservationType observation)
observation
 Observation to consider
protected void computeObservationLikelihoods(ObservationType observation, Vector b)
observation
 Observation to considerb
 Likelihood of each state generating the given observation. This is where
the result of the computation is stored.protected ArrayList<Vector> computeObservationLikelihoods(Collection<? extends ObservationType> observations)
observations
 Observation sequence to consider
protected WeightedValue<Vector> computeBackwardProbabilities(Vector beta, Vector b, double weight)
beta
 Beta from the "next" time step.b
 Observation likelihood from the "next" time step.weight
 Weight to use for the current time step.
protected ArrayList<WeightedValue<Vector>> computeBackwardProbabilities(ArrayList<Vector> b, ArrayList<WeightedValue<Vector>> alphas)
b
 Observation likelihoods.alphas
 Forward probabilities from which we will use the weights.
protected static Vector computeStateObservationLikelihood(Vector alpha, Vector beta, double scaleFactor)
alpha
 Forward probability at time n.beta
 Backward probability at time n.scaleFactor
 Amount to scale the gamma by
protected ArrayList<Vector> computeStateObservationLikelihood(ArrayList<WeightedValue<Vector>> alphas, ArrayList<WeightedValue<Vector>> betas, double scaleFactor)
alphas
 Forward probabilities.betas
 Backward probabilities.scaleFactor
 Amount to scale the gamma by
protected static Matrix computeTransitions(Vector alphan, Vector betanp1, Vector bnp1)
alphan
 Result of the forward pass through the HMM at time nbetanp1
 Result of the backward pass through the HMM at time n+1bnp1
 Conditionally independent likelihoods of each observation at time n+1
protected Matrix computeTransitions(ArrayList<WeightedValue<Vector>> alphas, ArrayList<WeightedValue<Vector>> betas, ArrayList<Vector> b)
alphas
 Result of the forward pass through the HMM.betas
 Result of the backward pass through the HMM.b
 Conditionally independent likelihoods of each observation.
public String toString()
toString
in class MarkovChain
protected WeightedValue<Integer> findMostLikelyState(int destinationState, Vector delta)
destinationState
 Destination state index to consider.delta
 Previous value of the "delta".
protected Pair<Vector,int[]> computeViterbiRecursion(Vector delta, Vector bn)
delta
 Previous value of the Viterbi recursion.bn
 Current observation likelihood.
@PublicationReference(author="Wikipedia", title="Viterbi algorithm", year=2010, type=WebPage, url="http://en.wikipedia.org/wiki/Viterbi_algorithm") public ArrayList<Integer> viterbi(Collection<? extends ObservationType> observations)
observations
 Observation sequence to consider
public ArrayList<Vector> stateBeliefs(Collection<? extends ObservationType> observations)
observations



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