1 Star 0 Fork 0

gzl2012/rbpf-gmapping

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Resample.m 993 Bytes
一键复制 编辑 原始数据 按行查看 历史
Adrian Llopart 提交于 2016-04-14 12:55 . Initial Update of all files
%% 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
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Matlab
1
https://gitee.com/gzl2012/rbpf-gmapping.git
git@gitee.com:gzl2012/rbpf-gmapping.git
gzl2012
rbpf-gmapping
rbpf-gmapping
master

搜索帮助