Package jline.lang.processes
Class MarkovProcess
java.lang.Object
jline.lang.processes.Process
jline.lang.processes.MarkovProcess
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
MarkedMarkovProcess
A class for a continuous time Markov chain
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMarkovProcess(Matrix infGen) Creates a CTMC with the specified infinitesimal generatorMarkovProcess(Matrix infGen, boolean isFinite) Creates a CTMC with the specified infinitesimal generator and finite flagMarkovProcess(Matrix infGen, boolean isFinite, Matrix stateSpace) Creates a CTMC with the specified infinitesimal generator, finite flag, and state space -
Method Summary
Modifier and TypeMethodDescriptionAggregation-disaggregation over a macrostate partition.static MarkovProcessCreate CTMC from sample system aggregation (dispatches based on input type).static MarkovProcessCreate CTMC from a SampleResult containing multi-node state trajectories.static MarkovProcessfromSampleSysAggr(Matrix samples) Create CTMC from sample system aggregation (assuming unit sojourn times)static MarkovProcessfromSampleSysAggr(Matrix samples, Matrix sojournTimes) Create CTMC from sample system aggregationstatic MarkovProcessfromSampleSysAggr(Matrix samples, Matrix sojournTimes, int numStates) Create CTMC from sample system aggregationGet the infinitesimal generator matrixdoublegetProbState(int state) Get probability of a specific state using steady-state analysisgetProbState(Matrix state) Get probability of a specific state using Cramer's ruleGet the state spacebooleanbooleanisFinite()Check if the CTMC is finitestatic MarkovProcessrand(int nStates) Create a random CTMCsample()Sample from the CTMCsample(int n) Sample n state transitions from the CTMC starting from steady-stateSample n state transitions from the CTMCSensitivity of the stationary distribution to a scalar parameter.voidsetStateSpace(Matrix stateSpace) Set the state spacesolve()Solve the CTMC for steady-state probabilitiessolveRelative(int refstate) Equilibrium distribution relative to a reference state, i.e.Stochastic complement of a subset of states.stochCompFull(List<Double> I) Stochastic complement of a subset of states together with the blocks of the generator partitioned by I and its complement, and the return-path term T = Q12*inv(-Q22)*Q21, so that S = Q11 + T.timeAverage(Matrix pi0, double t) Time-averaged distribution over [0,t].toDTMC()Convert to DTMC using uniformizationtoDTMC(double q) Embedded jump chain, i.e.Get time-reversed CTMCtransientProb(Matrix pi0, double t) Distribution at time t from pi0, by Jensen uniformization.transientProb(Matrix pi0, double t, String method) Distribution at time t from pi0.
-
Field Details
-
infGen
-
stateSpace
-
isfinite
protected boolean isfinite
-
-
Constructor Details
-
MarkovProcess
Creates a CTMC with the specified infinitesimal generator- Parameters:
infGen- the infinitesimal generator matrix
-
MarkovProcess
Creates a CTMC with the specified infinitesimal generator and finite flag- Parameters:
infGen- the infinitesimal generator matrixisFinite- whether the CTMC is finite
-
MarkovProcess
Creates a CTMC with the specified infinitesimal generator, finite flag, and state space- Parameters:
infGen- the infinitesimal generator matrixisFinite- whether the CTMC is finitestateSpace- the state space representation
-
-
Method Details
-
toDTMC
Convert to DTMC using uniformization- Returns:
- the equivalent DTMC
-
toDTMC
-
toTimeReversed
Get time-reversed CTMC- Returns:
- time-reversed CTMC
-
setStateSpace
Set the state space- Parameters:
stateSpace- the state space matrix
-
getGenerator
Get the infinitesimal generator matrix- Returns:
- the generator matrix
-
getProbState
public double getProbState(int state) Get probability of a specific state using steady-state analysis- Parameters:
state- the state index (0-based)- Returns:
- the probability of the specified state
-
getProbState
Get probability of a specific state using Cramer's rule- Parameters:
state- the state vector (if state space is defined) or single state index- Returns:
- the probability matrix containing the state probability
-
solve
Solve the CTMC for steady-state probabilities- Returns:
- the steady-state probability vector
-
transientProb
Distribution at time t from pi0, by Jensen uniformization.- Parameters:
pi0- initial distribution, uniform when nullt- time point- Returns:
- the distribution at time t
-
transientProb
Distribution at time t from pi0.- Parameters:
pi0- initial distribution, uniform when nullt- time pointmethod- "unif" for Jensen uniformization, "foxglynn" for the Fox-Glynn weights, which avoid evaluating the Poisson terms directly- Returns:
- the distribution at time t
-
solveRelative
Equilibrium distribution relative to a reference state, i.e. with p(refstate) = 1. Unnormalized by construction, so it is defined even where the normalizing constant is not.- Parameters:
refstate- 0-based index of the reference state- Returns:
- the relative equilibrium distribution
-
aggregate
Aggregation-disaggregation over a macrostate partition.- Parameters:
MS- macrostates, each a list of 0-based state indicesmethod- "courtois" (param is the randomization rate q), "kms" or "takahashi" (param is the iteration count, default 10), or "multi" (param is the second-level partition, a List<List<Integer>>)param- the per-method parameter described above, may be null- Returns:
- the approximate stationary vector, the nearly-complete- decomposability index of the partition, and the largest index for which the approximation is meant to hold
-
timeAverage
Time-averaged distribution over [0,t].- Parameters:
pi0- initial distribution, uniform when nullt- horizon- Returns:
- the time-averaged distribution over [0,t]
-
sens
Sensitivity of the stationary distribution to a scalar parameter.- Parameters:
dQ- derivative of the generator with respect to the parameter- Returns:
- the derivative of the stationary distribution
-
stochComp
Stochastic complement of a subset of states. Use stochCompFull to also obtain the partitioned blocks.- Parameters:
I- 0-based indices of the states to retain- Returns:
- the generator of the complement on those states
-
stochCompFull
Stochastic complement of a subset of states together with the blocks of the generator partitioned by I and its complement, and the return-path term T = Q12*inv(-Q22)*Q21, so that S = Q11 + T. Twin of the MATLAB [S,Q11,Q12,Q21,Q22,T] = ctmc.stochCompFull(I) and of the Python stochCompFull, which return the same six matrices.- Parameters:
I- 0-based indices of the states to retain- Returns:
- the complement and the blocks it was built from
-
isFeasible
public boolean isFeasible()- Returns:
- true when the generator is a valid one
-
toEmbedded
Embedded jump chain, i.e. the DTMC of the states visited at transition epochs. Unlike toDTMC (uniformization) it does not preserve the stationary distribution, since it drops the holding times; an absorbing state stays absorbing.- Returns:
- the embedded DTMC
-
sample
Sample from the CTMC -
sample
Sample n state transitions from the CTMC starting from steady-state- Parameters:
n- number of state transitions to sample- Returns:
- matrix containing sampled states (column vector)
-
sample
Sample n state transitions from the CTMC- Parameters:
n- number of state transitions to samplepi0- initial state distribution (if null, uses steady-state)random- random number generator- Returns:
- matrix containing sampled states (column vector)
-
getStateSpace
Get the state space- Returns:
- the state space matrix
-
isFinite
public boolean isFinite()Check if the CTMC is finite- Returns:
- true if finite
-
rand
Create a random CTMC- Parameters:
nStates- number of states- Returns:
- random CTMC
-
fromSampleSysAggr
Create CTMC from sample system aggregation- Parameters:
samples- matrix where each row is a sample trajectory, each column is a time stepsojournTimes- matrix of sojourn times corresponding to each state in samples- Returns:
- CTMC constructed from samples by estimating transition rates
-
fromSampleSysAggr
Create CTMC from sample system aggregation- Parameters:
samples- matrix where each row is a sample trajectory, each column is a time stepsojournTimes- matrix of sojourn times corresponding to each state in samplesnumStates- number of states (if -1, infer from data)- Returns:
- CTMC constructed from samples by estimating transition rates
-
fromSampleSysAggr
Create CTMC from sample system aggregation (assuming unit sojourn times)- Parameters:
samples- matrix where each row is a sample trajectory, each column is a time step- Returns:
- CTMC constructed from samples with unit time steps
-
fromSampleSysAggr
Create CTMC from a SampleResult containing multi-node state trajectories. Matches MATLAB MarkovProcess.fromSampleSysAggr(sa) where sa has .state{} and .t fields.- Parameters:
sa- the SampleResult from sampleSysAggr()- Returns:
- CTMC constructed from sampled state trajectories
-
fromSampleSysAggr
Create CTMC from sample system aggregation (dispatches based on input type).- Parameters:
sa- the sample aggregation object (Matrix or SampleResult)- Returns:
- CTMC constructed from samples
-