function plotreflection(a,b)
% plots a 2 barrier reflection principle plot. input Brownian motion W    
W=[0 cumsum([ normrnd(.001,.02,1,1000),normrnd(-.001,.02,1,1000),  normrnd(.001,.02,1,500)  ])];  % length=2501
% rig things so W(751)= b at t=.3 and W(1751)=-a at t=.7   close=.2
t=0:.0004:1; u=.2;  W=W-t*W(2501)+t*u;  % W is now like a Brownian bridge ending at the point u.
plot(t,W,'k')
hold on
j=(1:2501);
j=min(j(W>=b));  % this is the index of the first time above b
z=t(j:2501);
plot(z,2*b-W(j:2501),'k--')
plot(t,b*ones(1,2501))
plot(t,-a*ones(1,2501))
j=(1:2501);   j=min(j(W<=-a));  % this is the index of the first time below -a
z=t(j:2501);
plot(z,-2*a-W(j:2501),'k-.')
hold off



