Class MarkovChain
-
- All Implemented Interfaces:
-
java.io.Serializable
public class MarkovChain extends Process
A class for a discrete time Markov chain
-
-
Field Summary
Fields Modifier and Type Field Description protected MatrixtransMatprotected MatrixstateSpaceprotected booleanisfiniteprotected Stringnameprotected List<NamedParam>params
-
Constructor Summary
Constructors Constructor Description MarkovChain(Matrix transMat)Creates a DTMC with the specified transition matrix MarkovChain(Matrix transMat, boolean isFinite)Creates a DTMC with the specified transition matrix and finite flag
-
Method Summary
Modifier and Type Method Description MarkovProcesstoCTMC()Convert to CTMC by subtracting identity matrix MarkovChaintoTimeReversed()Get time-reversed DTMC MatrixgetTransMat()Get the transition matrix voidsetStateSpace(Matrix stateSpace)Set the state space MatrixgetStateSpace()Get the state space booleanisFinite()Check if the DTMC is finite Matrixsample()Sample from the DTMC Matrixsample(int n)Sample n steps from the DTMC starting from initial distribution Matrixsample(int n, Matrix pi0, Random random)Sample n steps from the DTMC static MarkovChainrand(int nStates)Create a random DTMC static MarkovChainfromSampleSysAggr(Matrix samples)Create DTMC from sample system aggregation static MarkovChainfromSampleSysAggr(Matrix samples, int numStates)Create DTMC from sample system aggregation static MarkovChainfromSampleSysAggr(Object sa)Create DTMC from sample system aggregation (legacy interface) -
-
Constructor Detail
-
MarkovChain
MarkovChain(Matrix transMat)
Creates a DTMC with the specified transition matrix- Parameters:
transMat- the transition matrix
-
MarkovChain
MarkovChain(Matrix transMat, boolean isFinite)
Creates a DTMC with the specified transition matrix and finite flag- Parameters:
transMat- the transition matrixisFinite- whether the DTMC is finite
-
-
Method Detail
-
toCTMC
MarkovProcess toCTMC()
Convert to CTMC by subtracting identity matrix
- Returns:
the equivalent CTMC
-
toTimeReversed
MarkovChain toTimeReversed()
Get time-reversed DTMC
- Returns:
time-reversed DTMC
-
getTransMat
Matrix getTransMat()
Get the transition matrix
- Returns:
the transition matrix
-
setStateSpace
void setStateSpace(Matrix stateSpace)
Set the state space
- Parameters:
stateSpace- the state space matrix
-
getStateSpace
Matrix getStateSpace()
Get the state space
- Returns:
the state space matrix
-
isFinite
boolean isFinite()
Check if the DTMC is finite
- Returns:
true if finite
-
sample
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
Matrix sample(int n, Matrix pi0, Random random)
Sample n steps from the DTMC
- Parameters:
n- number of steps to samplepi0- initial state distribution (if null, uses uniform distribution)random- random number generator- Returns:
matrix containing sampled states (column vector)
-
rand
static MarkovChain rand(int nStates)
Create a random DTMC
- Parameters:
nStates- number of states- Returns:
random DTMC
-
fromSampleSysAggr
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
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 stepnumStates- number of states (if -1, infer from data)- Returns:
DTMC constructed from samples by estimating transition probabilities
-
fromSampleSysAggr
static MarkovChain fromSampleSysAggr(Object sa)
Create DTMC from sample system aggregation (legacy interface)
- Parameters:
sa- the sample aggregation object- Returns:
DTMC constructed from samples
-
-
-
-