Class MarkovChain

java.lang.Object
jline.lang.processes.Process
jline.lang.processes.MarkovChain
All Implemented Interfaces:
Serializable

public class MarkovChain extends Process
A class for a discrete time Markov chain
See Also:
  • Field Details

    • transMat

      protected Matrix transMat
    • stateSpace

      protected Matrix stateSpace
    • isfinite

      protected boolean isfinite
  • Constructor Details

    • MarkovChain

      public MarkovChain(Matrix transMat)
      Creates a DTMC with the specified transition matrix
      Parameters:
      transMat - the transition matrix
    • MarkovChain

      public MarkovChain(Matrix transMat, boolean isFinite)
      Creates a DTMC with the specified transition matrix and finite flag
      Parameters:
      transMat - the transition matrix
      isFinite - whether the DTMC is finite
  • Method Details

    • toCTMC

      public MarkovProcess toCTMC()
      Convert to CTMC by subtracting identity matrix
      Returns:
      the equivalent CTMC
    • toTimeReversed

      public MarkovChain toTimeReversed()
      Get time-reversed DTMC
      Returns:
      time-reversed DTMC
    • getTransMat

      public Matrix getTransMat()
      Get the transition matrix
      Returns:
      the transition matrix
    • setStateSpace

      public void setStateSpace(Matrix stateSpace)
      Set the state space
      Parameters:
      stateSpace - the state space matrix
    • getStateSpace

      public Matrix getStateSpace()
      Get the state space
      Returns:
      the state space matrix
    • isFinite

      public boolean isFinite()
      Check if the DTMC is finite
      Returns:
      true if finite
    • sample

      public Matrix sample()
      Sample from the DTMC
      Specified by:
      sample in class Process
      Returns:
      sampled value
    • sample

      public Matrix sample(int n)
      Sample n steps from the DTMC starting from initial distribution
      Parameters:
      n - number of steps to sample
      Returns:
      matrix containing sampled states (column vector)
    • sample

      public Matrix sample(int n, Matrix pi0, Random random)
      Sample n steps from the DTMC
      Parameters:
      n - number of steps to sample
      pi0 - initial state distribution (if null, uses uniform distribution)
      random - random number generator
      Returns:
      matrix containing sampled states (column vector)
    • rand

      public static MarkovChain rand(int nStates)
      Create a random DTMC
      Parameters:
      nStates - number of states
      Returns:
      random DTMC
    • fromSampleSysAggr

      public static MarkovChain fromSampleSysAggr(Matrix samples)
      Create DTMC from sample system aggregation
      Parameters:
      samples - matrix where each row is a sample trajectory, each column is a time step
      Returns:
      DTMC constructed from samples by estimating transition probabilities
    • fromSampleSysAggr

      public static MarkovChain fromSampleSysAggr(Matrix samples, int numStates)
      Create DTMC from sample system aggregation
      Parameters:
      samples - matrix where each row is a sample trajectory, each column is a time step
      numStates - number of states (if -1, infer from data)
      Returns:
      DTMC constructed from samples by estimating transition probabilities
    • fromSampleSysAggr

      public static MarkovChain fromSampleSysAggr(Object sa)
      Create DTMC from sample system aggregation (legacy interface)
      Parameters:
      sa - the sample aggregation object
      Returns:
      DTMC constructed from samples