LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
ctmc_simulate.m
1function [soujt,sts]=ctmc_simulate(Q, pi0, n)
2if isempty(pi0)
3 r=rand(length(Q),1); r=r/sum(r);
4end
5[~,st] = min(abs(rand-cumsum(pi0)));
6F = cumsum(Q - diag(diag(Q)),2); F=F./repmat(F(:,end),1,length(F));
7for i=1:n
8 sts(i) = st; soujt(i) = exprnd(-1/Q(st,st));
9 st = 1 + max([0,find( rand - F(st,:) > 0)]);
10end
11
12end