histogram-by ( seq quot: ( x -- bin ) -- hashtable )
Statistics > Computing histograms
Prev:histogram ( seq -- hashtable )
Next:histogram! ( hashtable seq -- hashtable )


Vocabulary
math.statistics

Inputs and outputs
seqa sequence
quota quotation with stack effect ( x -- bin )
hashtablea hashtable


Word description
Returns a hashtable where the keys are the elements of the sequence binned by being passed through quot, and the values are the number of times members of each bin appeared in that sequence.

Examples
! Count the number of times letters and non-letters appear in a sequence. USING: prettyprint math.statistics unicode.categories ; "aaa123bc" [ letter? ] histogram-by .
H{ { t 5 } { f 3 } }


Definition
USING: assocs ;

IN: math.statistics

: histogram-by ( seq quot: ( x -- bin ) -- hashtable )
[ inc-at ] sequence>hashtable ; inline