function y=kdslope(x,data);

% KDSLOPE     Numerical derivative of a KDE.
%
%             Example: S=snmd(100,[0.75 0.25]',[1 1/3]',[0 3/2]');
%                      x=[-4:0.01:4]; y=kdest1d(x,S,'knorm',0); plot(x,y);
%                      fzero1('kdslope',0,S)
%                      fzero1('kdslope',1.5,S)
%
%             KDSLOPE(X,DATA) calculates the derivative of the KDE based upon 
%             DATA at X using simple central differences.  The kernel function
%             and the smoothing parameter are defined within the routine.
%
%             Christian C. Beardah 1996

delta=1e-5;

x=[x-delta; x+delta];

z=kdest1d(x,data,'knorm',0);
y=(z(2,:)-z(1,:))/(2*delta);