function smc_simple(N,n)
system.sigma=0.01;
system.ny=0.02;

system.x=0.5;
apriori=[0 1];

x_1=apriori(:,1)*ones(1,N)+apriori(:,2:end)*(0.5-rand(1,N)); vahy=1/N*ones(1,N);
N_tresh=N/2;
stav=[]; hranice=stav;

for i=1:n
    x_0=my_sample(vahy,x_1);
    
    x_1=model_simple(x_0,system);
    
    system.x=model_simple(system.x,system);
    system.pozorovani=system.x+sqrt(system.ny)*randn;
    
    reziduum=system.pozorovani*ones(1,N)-x_1;
    p_v=exp(-(reziduum.^2/system.ny)/2);
    vahy=p_v/sum(p_v);
    
   %porovnani(x_1,vahy,system.x);
   
    if (1/(vahy*vahy')<N_tresh)
        [x_1 vahy]=my_resample(x_1,vahy);
       % porovnani(x_1(1,:),vahy,system.x(1));
    end

    %x_0=my_sample(vahy,x_1);    
    %H=kalman_filter(H,u(:,i),system);
    
    stav=[stav [system.x; mean(x_1,2)]];
    hranice=[hranice [min(x_1,[],2); max(x_1,[],2)]];
    %ztrata= ztrata+u'*system.gamma*u+(system.x-system.x_opt)'*system.ksi*(system.x-system.x_opt);

end
%plot(abs(stav(1,:)-stav(2,:))); hold on
kresli(stav,hranice)
end