⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sample.m

📁 Non-parametric density estimation
💻 M
字号:
function [points,ind] = sample(npd,Npts,ind)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% [pts,ind] = sample(kde,Npts)      -- sample Npts new points from a kde
%                            ,ind)  -- take the samples from the given indices
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Copyright (C) 2003 Alexander Ihler; distributable under GPL -- see README.txt

pts = getPoints(npd);
if (nargin < 3)
  points = zeros(getDim(npd),Npts); ind = zeros(1,Npts);
  bw  = getBW(npd);
  w = getWeights(npd); w = cumsum(w); w = w/w(end);
  randnums = randKernel(getDim(npd),Npts,getType(npd));
  t = [sort(rand(1,Npts)),10];

  ii = 1;
  for i=1:size(pts,2)
    while (w(i) > t(ii))
      points(:,ii) = pts(:,i) + bw(:,i).*randnums(:,ii);
      ind(ii) = i;
      ii = ii + 1;
    end;
  end;
else
  points = pts(:,ind) + getBW(npd,ind).*randKernel(getDim(npd),length(ind),getType(npd));
end;

⌨️ 快捷键说明

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