;+ ; NAME: mode ; PURPOSE: ; Calculate the mode (most common element in an array) ; optionally with binning ; ; INPUTS: ; KEYWORDS: ; OUTPUTS: ; ; HISTORY: ; Began 2004-04-23 17:48:23 by Marshall Perrin ;- FUNCTION mode,input,binsize=binsize h = histogram(input,binsize=binsize,omin=omin) if not(keyword_set(binsize)) then binsize=1 mh = max(h) i = where(h eq max(h)) iout = i*binsize+omin return,iout[0] end