ntime = 100;
npart = 1000;
steps=2*randi(2,ntime,npart)-3;
P=cumsum(steps);
figure(1)
plot(P)
ylabel('Position')
xlabel('Step Count')
title('1-D Random Walk')
figure(2)
histogram(P(ntime,:),20)