function [H,Proba, Matpn, Matln,changex, changin]=Evolution(TS,N,NPN,J,TO,I,R,epsilon, choixhasard)

%BioSystems 89(2007) 244-256
%G.Horcholle-Bossavit et al.
%Network activity

global seedscalevol 

x=clock;
x=100*(x(5)+2*x(6));
rand('seed',x)
if choixhasard==1
     seedscalevol=rand('seed');
 else
     rand('seed',seedscalevol)
     seedscalevol=rand('seed');
end
tomax=max(max(TO));
change=zeros(1,N);

for t=1+tomax:TS+tomax	
   for i=1:N                      
      temp=0;
      for j=1:N											
         temp=temp+J(i,j)*I(j,t-TO(i,j));                                                    
      end; 
      H(i,t)=temp+R(i,t)-1/2 ;
      if epsilon==0
         Proba(i,t)=He(H(i,t));
      else
         Proba(i,t)=sigmoid(H(i,t),epsilon);
      end;
      ha(i,t)=rand;     
      if (ha(i,t)<Proba(i,t))
         G(i,1)=1;										
      else G(i,1)=0;      
      end;
      if G(i,1)~=I(i,t-1)
         change(i)=change(i)+1;
      end
 end; 
   I(:,t)=G   ;											
end;
Matsepar=I;
Matpn=Matsepar(1:NPN,:);
Matln=Matsepar(NPN+1:N,:);
changex=change(1:NPN);
changin=change(NPN+1:N);