Skip to content

Instantly share code, notes, and snippets.

@sandyUni
Created October 17, 2016 08:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sandyUni/36d868dc8192432e2dbccd450d28bc43 to your computer and use it in GitHub Desktop.
Save sandyUni/36d868dc8192432e2dbccd450d28bc43 to your computer and use it in GitHub Desktop.
resample method in particle filter
function [ indx ] = resampleSystematic(w,N)
Q = cumsum(w);
T = linspace(0,1-1/N,N) + rand(1)/N;
T(N+1) = 1;
i=1;
j=1;
indx = zeros(N,1);
while (i<=N),
if (T(i)<Q(j)),
indx(i)=j;
i=i+1;
else
j=j+1;
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment