% opt = 0: plot everything
% opt = 1: plot only the PDF

function plot_intervals(intervals,opt)

%figure;

% set the binning 
UI = unique(intervals);
[a b] = hist(intervals,UI);
%[a b] = hist(intervals,length(intervals));

% clean zeros
tmp = find(a==0); a(tmp) = []; b(tmp) = [];
%for the ranked distribution:
a_ord = sort(a,'descend');

if opt == 0
    loglog(b, a, 'ko'); hold;
    loglog(b, a_ord, 'r.');
end

if opt==1
    loglog(b, a_ord./sum(a_ord), 'r');
end
    
