function [ count, bloc ] = hist_fast( w, bins ) % FastHist -- fast histogram tool % function [count, block] = fasthist(w,M) % w = data % M = number of bins % modify to work like matlab's histogram (to some extent) [ aa, bb ] = size( w ); if aa > bb w = w'; end M = length( bins ); half_bin_size = 0.5 * ( max(bins)-min(bins) ) / ( M - 1 ); %% q = (max(w) - min(w))/ M ; %% lo = min(w); % MatLab 5.0 assumes that input has middles of bins lo = min(bins) - half_bin_size; % redo for middle! hi = max(bins) + half_bin_size; q = (hi - lo)/ M ; x = sort( [ (0:(M-1)) floor( (w - lo) / q )] ); x(length(x)) = M-1; y = diff([(-1) x]) > .01 ; n = 1:length(x); cum = [n( y) (length(x)+1)]; count = (diff(cum)-1); count = count(1:M); bloc = lo + (0:(M-1)).*q; % % Part of TeachWave Version 0.550 % Built Wednesday, December 22, 1993 12:04:14 PM % This is Copyrighted Material % For Copying permissions see COPYING.m % Comments? e-mail wavelab@playfair.stanford.edu %