
% deterministic selection procedure

% (Kitagawa JCGS 1996)

function N_sons= resample(N,wn)
u=zeros(1,N);
N_sons=zeros(1,N);
dist=cumsum(wn);
aux=rand(1);
u=aux:1:(N-1+aux);
u=u./N;
j=1;
for i=1:N
   while (u(i)>dist(j))
      j=j+1;
   end
   N_sons(j)=N_sons(j)+1;
end


