?? 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 + -