function [ wnew ] = pf_reweight( x, w, z, Q, measurement )
%PF_CORRECTION Particle Filter correction step

nSamples = size(x, 3);

% Reweighting based on expected and actual measurement:
z_exp = measurement(x);

tmp = num2cell(z_exp,1);
wnew = w.*reshape(cellfun(@(x) mvnpdf(x, z, Q) ,tmp), nSamples, 1, 1);
wnew = wnew / sum(wnew);

end

