📄 rsmp.m
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -