File Exchange

image thumbnail

Simulate Continuous-Time Markov Chains

version 1.0.2 (4.43 KB) by Dana
This code can be used to simulate continuous-time Markov chains

8 Downloads

Updated 15 Jan 2021

View Version History

View License

There are two functions: (1) simCTMC.m is used to simulate jump times and the corresponding states that are jumped to, given a Q-matrix and a desired number of periods. (2) simCTMC_t.m uses the output of simCTMC.m to generate a time series simulation for the states.

Cite As

Dana (2021). Simulate Continuous-Time Markov Chains (https://www.mathworks.com/matlabcentral/fileexchange/79649-simulate-continuous-time-markov-chains), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (2)

Dana

zk chen, could you elaborate on the errors you encountered?

Here's an example you can run:

Q = [-0.08 0.04 0.04; 0.01 -0.05 0.04; 0.01 0.01 -0.02]; % Q matrix
nsim = 3; % number of parallel simulations to run
T = 50; % length of simulation
[jmptout,sttout] = simCTMC(Q,T,nsim); % get jump times and states after each jump
tvc = linspace(0,T,100)'; % dates at which to determine state in simulation
stt_time = simCTMC_t(tvc,jmptout,sttout); % simulations
figure
plot(stt_time') % plot the three simulations on the same axis

zk chen

I could not use it due to there exist some errors. Would you please make a example to perform simCTMC?

MATLAB Release Compatibility
Created with R2020a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!