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]. densitynormalizes by the total weight of the observations that actually landed in a bin, sosum(value[i] * width[i]) == 1even when some observations fell outside the edges.
Structs
HistStat: Select howhistogram_bins()andhistogram()normalize bins.BinRule: Let a rule choose how many bins a sample gets, instead of naming a count. Pass one tobin_edges(),shared_bin_edges(), orhistogram()’sbins.HistogramBins: A binned sample:len(edges) - 1bins,edgesascending, one entry invaluesper bin. Whathistogram_bins()returns and whathistogram()draws.