Skip to content
histogram

histogram

Mojo module 🡭

histogram

Histogram binning and one-call chart helpers.

The binning behavior matches numpy.histogram:

  • Every bin is half-open, [edges[i], edges[i + 1]), except the last, which is closed on the right so the sample maximum lands inside the histogram instead of falling off it.
  • Observations outside [edges[0], edges[-1]] are dropped, not clamped into the end bins.
  • A constant sample gets the range [v - 0.5, v + 0.5].
  • density normalizes by the total weight of the observations that actually landed in a bin, so sum(value[i] * width[i]) == 1 even when some observations fell outside the edges.

Structs

  • HistStat: Select how histogram_bins() and histogram() normalize bins.
  • BinRule: Let a rule choose how many bins a sample gets, instead of naming a count. Pass one to bin_edges(), shared_bin_edges(), or histogram()’s bins.
  • HistogramBins: A binned sample: len(edges) - 1 bins, edges ascending, one entry in values per bin. What histogram_bins() returns and what histogram() draws.

Functions