function yy = empiricalcdf(x, sample)
%-----------------------------------------
%    sample  -  input sample to form ecdf
%      x     -  value(s) to evaluate at
%-----------------------------------------
%     Example of use
%     > sample = randn(1,100);
%     > x = -4:0.01:4;
%     > plot( x, empiricalcdf(x, sample))
%-----------------------------------------
 n = length(sample);
 ssample=sort(sample);
 y = [0 (1:n)/n]; 
 x = x(:); yy=[];
 for j = 1:length(x)
 yy = [yy y(find(diff([0 (x(j) < ssample) 1])~=0))];
end
%
%Copyright (C) BV 2011
% 