代码拉取完成,页面将自动刷新
%% Resampling function
function [x_new, q_new, idx] = Resample(x, q, resampling_strategy)
Ns = length(q); % Ns = number of particles
switch resampling_strategy
case 'multinomial_resampling'
with_replacement = true;
idx = randsample(1:Ns, Ns, with_replacement, q);
case 'systematic_resampling'
% this is performing latin hypercube sampling on q
edges = min([0 cumsum(q)'],1); % protect against accumulated round-off
edges(end) = 1; % get the upper edge exact
u1 = rand/Ns;
% this works like the inverse of the empirical distribution and returns
% the interval where the sample is to be found
[~, idx] = histc(u1:1/Ns:1, edges);
otherwise
error('Resampling strategy not implemented')
end;
x_new = x(:,idx); % extract new particles
q_new = repmat(1/Ns, 1, Ns); % now all particles have the same weight
end
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。