% This program does the subway interview clear trials=10000; patience=1000; Repub=rand(patience,trials)<0.2; for t=1:trials for i=1:patience if Repub(i,t) R(t)=i; break end end end n=1:max(R); pR=histc(R,n)/trials; P=(0.8.^(n-1))*0.2; figure(1) bar(n,pR,'r') hold on plot(n,P,'b')