% This program computes the time varying probabilites 
% of a Markov Process using Uniformization
% The user must specify the generator matrix Q the 
% uniformization rate v, the number of state N
% the initial probability vector pi0
% the initial time value iv and the final time value fv
% the solution is placed in pit and time
% the number of terms in the uniformization sum m

time = iv;
I = eye(N);
P = 1/v*Q + I;
e = ones(N,1);
ss = .1;
iv1 = iv + ss; 
pit = pi0;
pimc = pi0;
pitemp = pi0;

for k = 1:m;

    foo  = pitemp*P;
     pimc = [pimc
            foo];
    pitemp = foo;
end

for t=iv1:ss:fv
  sum = zeros(1, N); 
  for k = 0:m;
    temp = pimc(k+1,1:N)*poisspdf(k, v*t);
    sum = sum +temp;
  end
  pit = [pit,
         sum];
  time = [time 
          t]; 
end

        
