% % macm 202 -- 04 feb 03 -- djm % % w6gap1.m: simulate street crossing process % % - use direct exponential distribution % clear % simulation of Nruns Nruns = 10000; mu = 1.0; K = 1; walk = K/mu; % bins for histogram & pseudorandom seed bins = (0:1/8/mu:5*walk); rand('state',7654321); wait_times = zeros(Nruns,1); car_data = zeros(Nruns,1); % simulation loop for k=1:Nruns; wait = 0; cars = 0; gap = -log(rand(1,1))/mu; while (gap