@PublicationReference(author="Wikipedia", title="Markov chain", type=WebPage, year=2010, url="http://en.wikipedia.org/wiki/Markov_chain") public class MarkovChain extends AbstractCloneableSerializable
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_NUM_STATES
Default number of states, 3.
|
protected Vector |
initialProbability
Initial probability Vector over the states.
|
protected Matrix |
transitionProbability
Transition probability matrix.
|
Constructor and Description |
---|
MarkovChain()
Default constructor.
|
MarkovChain(int numStates)
Creates a new instance of ContinuousDensityHiddenMarkovModel
with uniform initial and transition probabilities.
|
MarkovChain(Vector initialProbability,
Matrix transitionProbability)
Creates a new instance of ContinuousDensityHiddenMarkovModel
|
Modifier and Type | Method and Description |
---|---|
MarkovChain |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
protected static Vector |
createUniformInitialProbability(int numStates)
Creates a uniform initial-probability Vector
|
protected static Matrix |
createUniformTransitionProbability(int numStates)
Creates a uniform transition-probability Matrix
|
Vector |
getFutureStateDistribution(Vector current,
int numSteps)
Simulates the Markov chain into the future, given the transition Matrix
and the given current state-probability distribution, for the
given number of time steps into the future.
|
Vector |
getInitialProbability()
Getter for initialProbability.
|
int |
getNumStates()
Gets the number of states in the HMM.
|
Vector |
getSteadyStateDistribution()
Returns the steady-state distribution of the state distribution.
|
Matrix |
getTransitionProbability()
Getter for transitionProbability.
|
void |
normalize()
Normalizes this Markov chain.
|
protected void |
normalizeTransitionMatrix(Matrix A)
Normalizes the transition-probability matrix
|
protected static void |
normalizeTransitionMatrix(Matrix A,
int j)
Normalizes a column of the transition-probability matrix
|
void |
setInitialProbability(Vector initialProbability)
Setter for initialProbability
|
void |
setTransitionProbability(Matrix transitionProbability)
Setter for transitionProbability.
|
java.lang.String |
toString() |
public static final int DEFAULT_NUM_STATES
protected Vector initialProbability
protected Matrix transitionProbability
public MarkovChain()
public MarkovChain(int numStates)
numStates
- Number of states to use.public MarkovChain(Vector initialProbability, Matrix transitionProbability)
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.public MarkovChain 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 AbstractCloneableSerializable
protected static Vector createUniformInitialProbability(int numStates)
numStates
- Number of states to create the Vector forprotected static Matrix createUniformTransitionProbability(int numStates)
numStates
- Number of states to create the Matrix forpublic Vector getInitialProbability()
public void setInitialProbability(Vector initialProbability)
initialProbability
- Initial probability Vector over the states. Each entry must be
nonnegative and the Vector must sum to 1.public Matrix getTransitionProbability()
public void setTransitionProbability(Matrix transitionProbability)
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.public void normalize()
protected static void normalizeTransitionMatrix(Matrix A, int j)
A
- Transition probability matrix to normalize, modified by side effectj
- Column of the matrix to normalizeprotected void normalizeTransitionMatrix(Matrix A)
A
- Transition probability matrix to normalize, modified by side effectpublic int getNumStates()
public java.lang.String toString()
toString
in class java.lang.Object
public Vector getSteadyStateDistribution()
public Vector getFutureStateDistribution(Vector current, int numSteps)
current
- Current distribution of probabilities of the various states.numSteps
- Number of steps into the future to simulate.