N=100; n=2550; t=0:n; % tiempo x=zeros(1,n+1); x(1)=0; for i=1:n, u=rand; if (u< 0.5) x(i+1)=x(i); elseif (u < 0.5+0.5*x(i)/N), x(i+1)=x(i)-1; else x(i+1)=x(i)+1; end end stairs(0:n,x) m = max(-min(x),max(x)); axis([0 n -m m]); title('Cantidad de unos en el paseo en el hipercubo');