function [pdf bin dbin N Nout]=histneq(X,e)
% Normalized histogram using non-equally spaced bins.
%
% [pdf bin N]=histneq(X,edges); X is the data to bin, edges are the edges
% of the bins, pdf is probability of X being in each bin centered between
% edges, N is the total number in each bin of size sz. Values of X outside
% of edges are returned as Nout. sum(pdf.*dbin)=1.


% revision history:
% 07/03/95 Mark D. Shattuck <mds>   histneq.m

N0=length(X);

N=histc(X,[-inf e inf]);
bin=(e(2:end)+e(1:end-1))/2;
dbin=diff(e);

Nout=N([1 end-1]);

pdf=N(2:end-2)./dbin/(N0-sum(Nout));

