%delta = (max(cspec)-min(cspec)) / 80000 ;
%xs = min(cspec):delta:max(cspec);

%cspec = real(cspec) ;
lspec = real(log(cspec)) ;
delta = (max(lspec)-min(lspec)) / 40000 ;
xs = min(lspec)-2500*delta:delta:max(lspec)+2500*delta;

eta = log(3) / log(5) ;

%{
%for j = 1:length(lspec)
%  y = lspec(j) ;
%  line([2,3],[y,y]) ;
%end
%
%axis([0 5 -1 lspec(length(lspec))+1])
%}

xs = sort(xs) ;
length(xs)

newys = [] ;
for j = 1:length(xs)
  newys(j) = sum(xs(j) > lspec) / (exp(xs(j)))^eta ;
end

hold off
%{
jumps = [] ;
for i = 1:(length(newys)-1)
  if(newys(i+1) > newys(i))
    jumps = [jumps xs(i)] ;
  end
end

M = max(newys./exp(xs).^eta) ;
for i = 1:length(jumps)
  plot([jumps(i) jumps(i)],[0 M],'Color',[0 1 1],'LineStyle','-') ;   
  hold on
  %  plot(jumps,400*ones(size(jumps)),'Color',[1 0 0],'LineStyle','.','Marker','*') ;  
end

hold on
%}
%newys = newys./ exp(xs).^eta ;
plot(xs,newys,'.k','MarkerSize',1) ;

%plot(xs,lspec+0.2*ones(size(lspec)),'.r') ;
