Package jline.lang.processes
Class MarkovChain
java.lang.Object
jline.lang.processes.Process
jline.lang.processes.MarkovChain
- All Implemented Interfaces:
Serializable
A class for a discrete time Markov chain
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMarkovChain(Matrix transMat) Creates a DTMC with the specified transition matrixMarkovChain(Matrix transMat, boolean isFinite) Creates a DTMC with the specified transition matrix and finite flag -
Method Summary
Modifier and TypeMethodDescriptionstatic MarkovChainCreate DTMC from sample system aggregation (legacy interface)static MarkovChainfromSampleSysAggr(Matrix samples) Create DTMC from sample system aggregationstatic MarkovChainfromSampleSysAggr(Matrix samples, int numStates) Create DTMC from sample system aggregationGet the state spaceGet the transition matrixhittingTime(int[] targetStates) Mean number of steps to reach any target state.booleanbooleanisFinite()Check if the DTMC is finitestatic MarkovChainrand(int nStates) Create a random DTMCsample()Sample from the DTMCsample(int n) Sample n steps from the DTMC starting from initial distributionSample n steps from the DTMCvoidsetStateSpace(Matrix stateSpace) Set the state spacesolve()Solve the DTMC for steady-state probabilities.Stochastic complement of a subset of states.stochCompFull(List<Integer> I) Stochastic complement of a subset of states together with the four blocks of the transition matrix partitioned by I and its complement.toCTMC()Convert to CTMC by subtracting identity matrixGet time-reversed DTMCtransientProb(Matrix pi0, int steps) Distribution at each step 0,...,steps.transientUnif(Matrix pi0, double t) Distribution at time t of the DTMC seen through uniformization.
-
Field Details
-
transMat
-
stateSpace
-
isfinite
protected boolean isfinite
-
-
Constructor Details
-
MarkovChain
Creates a DTMC with the specified transition matrix- Parameters:
transMat- the transition matrix
-
MarkovChain
Creates a DTMC with the specified transition matrix and finite flag- Parameters:
transMat- the transition matrixisFinite- whether the DTMC is finite
-
-
Method Details
-
toCTMC
Convert to CTMC by subtracting identity matrix- Returns:
- the equivalent CTMC
-
toTimeReversed
Get time-reversed DTMC- Returns:
- time-reversed DTMC
-
getTransMat
Get the transition matrix- Returns:
- the transition matrix
-
solve
Solve the DTMC for steady-state probabilities. Twin of MarkovProcess.solve.- Returns:
- the steady-state probability vector
-
transientProb
Distribution at each step 0,...,steps.- Parameters:
pi0- initial distribution, uniform when nullsteps- number of steps- Returns:
- matrix with one row per step
-
hittingTime
Mean number of steps to reach any target state.- Parameters:
targetStates- 0-based indices of the target states- Returns:
- column vector of mean hitting times
-
stochComp
Stochastic complement of a subset of states.- Parameters:
I- 0-based indices of the states to retain- Returns:
- the transition matrix of the complement on those states
-
stochCompFull
Stochastic complement of a subset of states together with the four blocks of the transition matrix partitioned by I and its complement. Twin of the MATLAB [S,P11,P12,P21,P22] = dtmc.stochCompFull(I) and of the Python stochCompFull.- Parameters:
I- 0-based indices of the states to retain- Returns:
- the complement and the blocks it was built from
-
transientUnif
Distribution at time t of the DTMC seen through uniformization. The chain is read as the randomized image of a CTMC, so t is continuous here, unlike the step count taken by transientProb.- Parameters:
pi0- initial distribution, uniform when nullt- time point- Returns:
- the distribution at time t
-
isFeasible
public boolean isFeasible()- Returns:
- true when the transition matrix is stochastic
-
setStateSpace
Set the state space- Parameters:
stateSpace- the state space 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
Sample from the DTMC -
sample
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
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
Create a random DTMC- Parameters:
nStates- number of states- Returns:
- random DTMC
-
fromSampleSysAggr
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
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
Create DTMC from sample system aggregation (legacy interface)- Parameters:
sa- the sample aggregation object- Returns:
- DTMC constructed from samples
-