p=0.5; n=100; t=1:n; y=rand(1,n); figure x=-(y<=0.5)+(y>0.5); plot(x,'o') axis([0,100,-2,2]) p=0.6; x=-(y<=p)+(y>p); figure plot(x,'o') axis([0,100,-2,2]) %nahodna prochazka x=x'*ones(1,n); xt=triu(x); S=sum(xt); figure plot(S) p=0.5; x=-(y<=p)+(y>p); S=sum(triu(x'*ones(1,n))); figure plot(S)