histogram-by ( seq quot: ( x -- bin ) -- hashtable )

Statistics ยป Computing histograms

Statistics ยป Computing histograms

Prev: | histogram ( seq -- hashtable ) |

Next: | histogram! ( hashtable seq -- hashtable ) |

Vocabulary

math.statistics

Inputs

Outputs

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

Definition

math.statistics

Inputs

seq | a sequence |

quot | a quotation with stack effect ( x -- bin ) |

Outputs

hashtable | a 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 ;
"aaa123bc" [ letter? ] histogram-by .

H{ { t 5 } { f 3 } }

H{ { t 5 } { f 3 } }

Definition

This documentation was generated offline from a
`load-all`

image. If you want, you can also
browse the documentation from within the UI developer tools. See
the Factor website
for more information.

Factor 0.99 x86.64 (2190, heads/master-b44db33e34, Jan 31 2023 20:58:13)