Code covered by the BSD License  

Highlights from
Resampling methods for particle filtering

image thumbnail
from Resampling methods for particle filtering by Jose-Luis Blanco
Implementation of four resampling methods (Multinomial, Residual, Stratified, and Systematic)

resampleSystematic( w )
function [ indx ] = resampleSystematic( w )

N = length(w);
Q = cumsum(w);

T = linspace(0,1-1/N,N) + rand(1)/N;
T(N+1) = 1;

i=1;
j=1;

while (i<=N),
    if (T(i)<Q(j)),
        indx(i)=j;
        i=i+1;
    else
        j=j+1;        
    end
end


Contact us at files@mathworks.com