# SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.stats.markovchain

## Class SimpleMC

• All Implemented Interfaces:
RandomNumberGenerator, Seedable
Direct Known Subclasses:
HMMRNG

public class SimpleMC
extends Object
implements RandomNumberGenerator
This is a time-homogeneous Markov chain with a finite state space. It is a mathematical system that undergoes transitions from one state to another, between a finite or countable number of possible states. It is a random process characterized as memoryless: the next state depends only on the current state and not on the sequence of events that preceded it. This specific kind of "memorylessness" is called the Markov property.
See Also:
Wikipedia: Markov chain
• ### Constructor Summary

Constructors
Constructor and Description
SimpleMC(Vector PI, Matrix A)
Constructs a time-homogeneous Markov chain with a finite state space.
• ### Method Summary

All Methods
Modifier and Type Method and Description
ImmutableMatrix A()
Gets the state transition probabilities.
static int bin(MultinomialRVG rvg)
Picks the first non-empty bin.
static Vector getStationaryProbabilities(Matrix A)
Gets the stationary state probabilities of a Markov chain that is irreducible, aperiodic and strongly connected (positive recurrent).
double nextDouble()
Gets the next simulated state.
int nextState()
Gets the next simulated state.
int nStates()
Gets the number of states.
ImmutableVector PI()
Gets the initial state probabilities.
void seed(long... seeds)
Seed the random number/vector/scenario generator to produce repeatable experiments.
• ### Methods inherited from class java.lang.Object

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

• #### SimpleMC

public SimpleMC(Vector PI,
Matrix A)
Constructs a time-homogeneous Markov chain with a finite state space.
Parameters:
PI - the initial state probabilities
A - the state transition probabilities
• ### 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
Parameters:
seeds - the seeds
• #### nextDouble

public double nextDouble()
Gets the next simulated state.
Specified by:
nextDouble in interface RandomNumberGenerator
Returns:
next state
• #### nextState

public int nextState()
Gets the next simulated state.
Returns:
next state
• #### PI

public ImmutableVector PI()
Gets the initial state probabilities.
Returns:
the initial state probabilities
• #### A

public ImmutableMatrix A()
Gets the state transition probabilities.
Returns:
the state transition probabilities
• #### nStates

public int nStates()
Gets the number of states.
Returns:
the number of states
• #### getStationaryProbabilities

public static Vector getStationaryProbabilities(Matrix A)
Gets the stationary state probabilities of a Markov chain that is irreducible, aperiodic and strongly connected (positive recurrent). A stationary distribution vector x (if exists) satisfies $x' \times A = x'$ where x' denotes the transpose of x, and the sum of all elements of x is 1.
Parameters:
A - the transition matrix
Returns:
the stationary state probabilities
• #### bin

public static int bin(MultinomialRVG rvg)
Picks the first non-empty bin.
Parameters:
rvg - a MultinomialRVG
Returns:
the first non-empty bin

Copyright © 2010-2018 Numerical Method Incorporation Limited. All Rights Reserved.