Class DMarkovChain


  • public class DMarkovChain
    extends java.lang.Object
    Randomly generates the states of a discrete Markov Chain. Assumes that the states are labeled 1, 2, 3, etc. The transition probabilities are supplied as an array of arrays. cdf[0] holds the array of transition probabilities for transition to each state {p11, p12, p13, .., p1n} for state 1 cdf[1] holds the array of transition probabilities for transition to each state {p21, p22, p23, .., p2n} for state 2 etc.
    • Field Detail

      • myRNG

        protected RNStreamIfc myRNG
        myRNStream provides a reference to the underlying stream of random numbers
    • Constructor Detail

      • DMarkovChain

        public DMarkovChain​(int initialState,
                            double[][] prob)
        Parameters:
        initialState - the initial starting state as an integer
        prob - the transition probability array, holds the probabilities across the states
      • DMarkovChain

        public DMarkovChain​(int initialState,
                            double[][] prob,
                            RNStreamIfc rng)
        Parameters:
        initialState - the initial starting state as an integer
        prob - the transition probability array, holds the probabilities across the states
        rng - the random number stream
    • Method Detail

      • reset

        public final void reset()
        Sets the state back to the initial state
      • setInitialState

        public final void setInitialState​(int initialState)
        Parameters:
        initialState - the initial state, must be 1, 2, etc. to number of states
      • getInitialState

        public final int getInitialState()
        Returns:
        the initial state for the chain
      • setState

        public final void setState​(int state)
        Causes the chain to be in the supplied state, without any transition
        Parameters:
        state - the state to be in
      • getState

        public final int getState()
        Returns:
        the current state, without the transition
      • next

        public final int next()
        Causes a transition to the next state and returns it
        Returns:
        the next state
      • getRandomNumberGenerator

        public final RNStreamIfc getRandomNumberGenerator()
      • setRandomNumberGenerator

        public final void setRandomNumberGenerator​(RNStreamIfc rng)
        Sets the underlying random number generator for the distribution Throws a NullPointerException if rng is null
        Parameters:
        rng - the reference to the random number generator
      • advanceToNextSubstream

        public void advanceToNextSubstream()
      • resetStartStream

        public void resetStartStream()
      • resetStartSubstream

        public void resetStartSubstream()
      • setAntitheticOption

        public void setAntitheticOption​(boolean flag)
      • getAntitheticOption

        public boolean getAntitheticOption()
      • main

        public static void main​(java.lang.String[] args)
        Parameters:
        args - the command line arguments