Home > sp > hitting.m

hitting

PURPOSE ^

hitting.m displays the distribution of the first hitting time of state j

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 hitting.m displays the distribution of the first hitting time of state j

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % hitting.m displays the distribution of the first hitting time of state j
0002 
0003 % define the transition matrix P before running hitting.m
0004 
0005 j = 1;  % the state to be hit
0006 Q = P;
0007 Q(:,j) = P(:,j)*0;  % set this column to zero
0008 
0009 F = P(:,j);
0010 H = F;
0011 
0012 for k=1:21,
0013   F = Q*F;
0014   H = [H F];
0015 end
0016   
0017 fprintf('Values of H(i,k), the probability, starting at i, of hitting state %d at time k\n', j);
0018 
0019 for k = 1:length(H(1,:)),
0020   fprintf('    %2d  ', k);
0021 end
0022 fprintf('\n');
0023 
0024 showmatrix(H); % H(i,k) is the probability, starting at i, of hitting j for
0025                % the first time at time k
0026 
0027 F = P(:,j);
0028 A = F;
0029 
0030 for k=1:5000,
0031   F = Q*F;     % compute F_{k}(i,j)
0032   A = A + F;   % add these up
0033 end
0034 
0035 fprintf('The row sum, the probability, starting at i, of ever hitting state %d\n', j);
0036 
0037 showmatrix(A); % A(i) is the probability of ever hitting j after time 0,
0038                % starting at i
0039

Generated on Mon 17-Mar-2008 10:33:42 by m2html © 2003