histogram

std.stats.histogram · Level L3

Counts per bin for increasing bin edges, with NumPy's rules: half-open bins, the last one closed, values outside the edges not counted. Each value's bin comes from comparisons, becomes an integer slot with Cast, and is counted with ScatterAdd.

cᵢ = #{ x : eᵢ ≤ x < eᵢ₊₁ }

Signature

histogram(x: f64[n], edges: f64[m]) → f64[m−1]

Requires: m ≥ 2

Structure

The function as NOVA stores it: one box per input, operation and output, and arrows that carry values. A double border marks another library function this one runs — called once, or by Scan once per element; select it to open that function.

edgesf64[m]xf64[n]0.0SizemReshapeerReshapexcSlicelastMultiplyedge_zeros[0.0]Multiplyx01.0GreateraboveEqualon_lastConcatslotsAddonesReduceSumn_aboveSubtractat_or_belowSubtractbucketCastslotScatterAddfilledSlicecountscountsf64[m−1]
  • input
  • operation
  • constant
  • call
  • output

Verification

  • Signature proven by NOVA’s shape solver, for every size with m ≥ 2.
  • Equal to the reference np.histogram(x, edges)[0] in exact rational arithmetic, on all 40 test cases.
  • All 134 float64 results are exact: the error is zero.
  • Interpreter and NumPy backend return bit-identical results.
Accuracy in detail
correctly rounded (the float64 nearest the exact value)
100%
bit-equal to the NumPy formula in float64
87%
largest error, in units in the last place
0

Note

Slot 0 collects values below the first edge and slot m values above the last; both are sliced away. A value equal to the last edge moves down one slot, into the closed last bin.

Identity

Calls
—
Called by
—
sha256:db7302996d18bbe30c61607e1186a2594edd8752a3fa3fda74a26871a812d9fa

The semantic hash of the graph. It changes when the program changes, and never when only its documentation does.

Control handle

Symbol
Ω:std.stats.histogram · Ω:histogram
Pins
sha256:a5a32a635f8b5d11d042fa92ac9d467fdff5a3bd67c60dca54088676f333e1b6this graph alone
Evidence
sha256:3e3cb40f52a9682189843265d5f9750e378c74b6307c03dd3812e99cc28a8522the hash of its verification record
Needs
no capability: a pure function

Through NOVA’s control layer, the symbol launches this function only while the program still matches what it pins: a change to this graph, or to any graph it reaches, needs a migration first.