📄 process.m
字号:
% process.m simulates a Markov process on a state space S, using initial% distribution mu, sojourn parameters lambda, and jump matrix Q.clear T;clear x; % clear out previous valuesT(1) = 0; % start times at 0x(1) = rando(mu); % generate first x value (time 0, not time 1)i = 1;while T(i) < Tmax, T(i+1) = T(i) - log(rand)/lambda(x(i)); % generate exponential rv % occasionally causes errors; ignore them x(i+1) = rando(Q(x(i),:)); % use Q to make state transitions i=i+1;endcla;hold onfor i=1:(length(T)-1), plot([T(i) T(i+1)], [S(x(i)) S(x(i))]);end%stairs(T,S(x)); % sometime this is more appropriateaxis([0 Tmax 0 (length(mu)+1)]);xlabel('Time');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -