pro histo,data,minx,maxx,dx,histp,binc,median,mean,stdev ;-------------------------------------------------------------------------------- ; Compute a histogram for the input data ; ; Input: ; data....vector of data to examine ; minx....minimum data value to consider, data units ; maxx....maximum data value to consider, data units ; dx....data interval for histogram, data units ; ; Output: ; histp...probability (%) of data value ; binc....data bin center values, data units ; median..the most frequently occuring data value ; mean....the mean data value ; stdev...the standard deviation of the mean ; ; To plot a histogram of your data, plot,binc,histp ; ; Source: Mark Hervig ;-------------------------------------------------------------------------------- ;- define the histogram bins nbin = round( (maxx-minx) / dx) + 1 bin = findgen(nbin) * dx + minx ; the histogram bins binc = bin + dx/2.0 ; the bin centers ;- calculate the histogram ok = where(data ge minx and data le maxx,nok) hist = histogram(data(ok),nbins=nbin,min=minx,binsize=dx) histp = 100.0 * hist / float(nok) ; the histogram in percent k = where(hist eq max(hist),n) & k=k(0) median = binc(k) r = moment(data(ok)) mean = r(0) stdev = sqrt(r(1)) return end