% % Written by: % -- % John L. Weatherwax 2007-09-10 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- close all; drawnow; clc; clear; p = [ 0.2, 0.3, 0.4, 0.5, 0.6, 0.7 ]; q = 1-p; % the probability of ending in state 5: p5 = ( 1 ./ (1 - p.^2 .* q) ) .* ( p.^3 ) .* ( 1 + q ); % the expected number of steps: es = ( 1 + p + p.^2 .* q + p.^2 ) ./ ( 1 - p.^2 .* q); [ p; p5; es ]