function yy =  empiricalcdf(x, sample)
%-----------------------------------------
% sample - input sample
%      x - value to evaluate at
%-----------------------------------------
 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
