function H_new=generate_trajectories(H_old,mi)
eps=10^-4;
H_new=zeros(size(H_old));
H_new(1,:,:)=H_old(1,:,:);

for j=1:size(H_old,2)
    index=j;    
    
    for i=1:size(H_old,1)-1
        eta_0=H_new(i,index,1)/(1+eps-H_new(1,index,1));
        beta_0=sqrt(H_new(i,index,2)/(1+eps-H_new(i,index,2)));
        s=randn;
        
        u=-mi(i,index)*eta_0/(beta_0+eps);

        
        eta_1=abs(eta_0+beta_0*u+sqrt(1+u^2)*s);
        beta_1=sqrt(1+u^2)*beta_0+u*s;
        
        H_new(i+1,j,1)=eta_1/(1+eta_1);
        H_new(i+1,j,2)=beta_1^2/(1+beta_1^2);
        pom(1,:)=H_new(i+1,j,:);
        index=find_in_hyperstate5(pom,H_old(i+1,:,:));
        
       % plot(H_new(i+1,j,1),H_new(i+1,j,2),'r+'); hold on
       % plot(H_old(i+1,index,1),H_old(i+1,index,2),'b+');  plot(H_old(i+1,:,1),H_old(i+1,:,2),'g.'); hold off
    end
   % plot(H(i,:,1),H(i,:,2),'g.'); hold on
   
end
end