demo_regress.m

来自「Non-parametric density estimation」· M 代码 · 共 23 行

M
23
字号
% Simple Example #3 -- products of gaussian mixtures
%
%
fprintf('Example: Kernel Regression with KDE toolbox\n');
rand('state',0);
randn('state',0);

x = rand(1,200);
y = sin(2*pi*x) + .05*randn(1,200);
bwType = {'rot','lcv','local'}; color = ['g','r','m'];
plot(x,y,'bo');
for j=1:length(bwType)
  px = kde(x,bwType{j}); bwx = getBW(px,1);
  p = kde([x;y],[bwx;0]);
  xx = 0:.01:1; yy = 0*xx;
  for i=1:length(xx)
    yy(i) = mean(condition(p,1,[xx(i);0]));
  end;
  hold on; tmp=plot(xx,yy,[color(j),'-']); set(tmp,'LineWidth',2); hold off;
end;
legend('Samples','ROT kernel size','Likelihd X-Val','Local L. X-val');

⌨️ 快捷键说明

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