function yy =  empiricalcdf(xx, sample)
%-----------------------------------------
% sample - input sample
%      xx - value to evaluate at
%-----------------------------------------
 N = length(sample);
 ssample=sort(sample(:))';
 y = [0 (1:N)/N]; 
 xx = xx(:); yy=[];
 for k = 1:length(xx)
 yy = [yy y(find(diff([0 (xx(k) < ssample) 1])~=0))];
end
