# SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.stats.hmm

## Class HMMRNG

• All Implemented Interfaces:
RandomNumberGenerator, Seedable
Direct Known Subclasses:
HiddenMarkovModel, KnightSatchellTran1995

public class HMMRNG
extends SimpleMC
In a (discrete) 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 (could be continuous). Therefore the sequence of tokens generated by an HMM gives some information about the sequence of states. Note that the adjective 'hidden' refers to the state sequence through which the model passes, not to the parameters of the model; even if the model parameters are known exactly, the model is still 'hidden'. In other words, a hidden Markov model is a Markov chain of (hidden) states and for each state a conditional random number generator (distribution).
Wikipedia: Hidden Markov model
• ### Constructor Summary

Constructors
Constructor and Description
HMMRNG(HMMRNG that)
Copy constructor.
HMMRNG(Vector PI, Matrix A, RandomNumberGenerator[] B)
Constructs a hidden Markov model.
• ### Method Summary

All Methods
Modifier and Type Method and Description
HmmInnovation next()
Gets the next simulated innovation: state and observation.
double nextDouble()
Gets the next simulated observation.
void seed(long... seeds)
Seed the random number/vector/scenario generator to produce repeatable experiments.
• ### Methods inherited from class com.numericalmethod.suanshu.stats.markovchain.SimpleMC

A, bin, getStationaryProbabilities, nextState, nStates, PI
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### Constructor Detail

• #### HMMRNG

public HMMRNG(Vector PI,
Matrix A,
RandomNumberGenerator[] B)
Constructs a hidden Markov model.
Parameters:
PI - the initial state probabilities
A - the state transition probabilities of the homogeneous hidden Markov chain
B - the conditional observation random number generators (distributions)
• #### HMMRNG

public HMMRNG(HMMRNG that)
Copy constructor.
Parameters:
that - a HiddenMarkovModel
• ### Method Detail

• #### seed

public void seed(long... seeds)
Description copied from interface: Seedable
Seed the random number/vector/scenario generator to produce repeatable experiments.
Specified by:
seed in interface Seedable
Overrides:
seed in class SimpleMC
Parameters:
seeds - the seeds
• #### nextDouble

public double nextDouble()
Gets the next simulated observation.
Specified by:
nextDouble in interface RandomNumberGenerator
Overrides:
nextDouble in class SimpleMC
Returns:
next observation
• #### next

public HmmInnovation next()
Gets the next simulated innovation: state and observation.
Returns:
the next HMM innovation