function count=chkbump1(p,tol,w,sigma,mu)

% CHKBUMP1    Compare KDE bumps to true NMD bumps (1D case).
%
%             Example: data=snmd(1000,[0.75 0.25]',[1 1/3]',[0 3/2]');
%                      h=hns(data,'knorm');
%                      x = -5:0.1:5;
%                      y = kdest1d(x,data,'knorm',h);
%                      [p,c]=bump1(x,y,0.01);
%                      plot(x,y); hold on; plot(p(:,1),p(:,2),'x'); 
%                      count=chkbump1(p,0.5,[0.75 0.25]',[1 1/3]',[0 3/2]')
%
%             CHKBUMP1(P,TOL,W,SIGMA,MU)
%
%             Christian C. Beardah 1997

[n,c]=size(p); % n = number of bumps in sample.
count=zeros(length(w)+1,1);
count(length(w)+1,1)=n; % Record number of bumps in sample.

for i=1:length(w),
  for j=1:n,

% A "success" is when a KDE bump is within sigma*tol of a true bump.

    if abs(p(j,1)-mu(i))<(sigma(i)*tol),
      count(i)=count(i)+1;
    end;
  end;
end;