Package dev.nm.stat.markovchain
Class SimpleMC
- java.lang.Object
-
- dev.nm.stat.markovchain.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
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ImmutableMatrixA()Gets the state transition probabilities.static intbin(MultinomialRVG rvg)Picks the first non-empty bin.static VectorgetStationaryProbabilities(Matrix A)Gets the stationary state probabilities of a Markov chain that is irreducible, aperiodic and strongly connected (positive recurrent).doublenextDouble()Gets the next simulated state.intnextState()Gets the next simulated state.intnStates()Gets the number of states.ImmutableVectorPI()Gets the initial state probabilities.voidseed(long... seeds)Seed the random number/vector/scenario generator to produce repeatable experiments.
-
-
-
Method Detail
-
seed
public void seed(long... seeds)
Description copied from interface:SeedableSeed the random number/vector/scenario generator to produce repeatable experiments.
-
nextDouble
public double nextDouble()
Gets the next simulated state.- Specified by:
nextDoublein interfaceRandomNumberGenerator- 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- aMultinomialRVG- Returns:
- the first non-empty bin
-
-