function res=wrifi(m,n,N,i) X=zeros(m,n); // on simule m trajectoires de longueur n indice=[]; temp0=[]; tempN=[]; for k=1:m z=i*ones(1,n); for j=1:(n-1); z(1,j+1)=grand(1,1,"bin",N,z(1,j)/N); end X(k,:)=z; // on ne retient que les marches qui touchent zero ou N test1=bool2s((X(k,$)==0)); test2=bool2s((X(k,$)==N)); if (test1==1) then indice=[indice ; k]; temp0=[temp0 ; sum(bool2s((z>0)))+1]; elseif (test2==1) then indice=[indice ; k]; tempN=[tempN ; sum(bool2s(((N-z)>0)))+1]; end end Z=X(indice,:); dernier=Z(:,$)/N; x=i/N; a=-2*N*(x*log(x)+(1-x)*log(1-x)); b=mean(temp0); c=mean(tempN); d=mean([temp0 ; tempN]); res=[mean(dernier) a b c d]; endfunction