rsmp.m

来自「matlab环境下粒子滤波器demo」· M 代码 · 共 17 行

M
17
字号
function Inew=rsmp(pik,N)
%picks N indeces from pik randomly. The probability of a certain element is proportional to the size of the corresponding element in pik.
%Author PSL 200411
akkupik=cumsum(pik);

Inew=zeros(N,1);
y=rand(1)/N;
j=1;
for i=1:N        
    while(akkupik(j)<y)%flush all values that are below the current level of integrated propability
        j=j+1;        
    end
    Inew(i)=j;
    y=y+1/N;
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?