Key takeaway

A value equal to the last edge can be inside the final displayed bin or in overflow. Keep that rule beside the counts.

A missing final-bin value may be a method difference

An export summary places two observations in its final bin; a receiving query counts one. The total source records agree and the values have not changed. Before searching for lost rows, inspect which side of each interval owns a boundary and how the implementation represents overflow. A picture labelled histogram does not define those rules.

NumPy documents half-open bins except for its final bin, which includes the rightmost edge. Its range parameter also defines which outside values are ignored. These choices can be valid for a declared calculation, but they must be preserved when another tool reconstructs the summary. Bin edges alone are insufficient if endpoint semantics differ.

Supporting referencesnumpy.histogram

Retain all three invented boundary values

This hypothetical fixture contains exactly three equally weighted scalar observations: 0,10,20. The two displayed intervals use edges 0,10,20. There are no missing values, weights, rounded measurements or density normalization. Applying the documented NumPy histogram convention puts 0 in [0,10) and both 10 and 20 in [10,20], producing counts 1 and 2.

For PostgreSQL’s equal-width overload width_bucket(x,0,20,2), the first two buckets have inclusive lower and exclusive upper bounds. The same values receive bucket identifiers 1,2,3. Identifier 3 is overflow because x is greater than or equal to high. A report showing only buckets 1 and 2 therefore contains two observations while the third remains an explicit overflow, rather than a missing source record. These are definition-based calculations, not executed NumPy or SQL results.

Synthetic valueNumPy bins [0,10,20]width_bucket(x,0,20,2)
0First bin [0,10)1
10Last bin [10,20]2
20Last bin [10,20]3: high-bound overflow

Keep the overload and the denominator together

PostgreSQL documents the equal-width function’s below-low bucket 0 and at-or-above-high bucket count+1. It also provides a thresholds-array overload with its own contract. Retain which form was used, the actual arguments and the ordering of any thresholds. Do not copy a rule between overloads merely because both functions share a name.

For the illustration, NumPy’s two counts sum to 3. The SQL-style displayed in-range counts sum to 2, with overflow 1; including that category reconciles to the same three input observations. If a visualization suppresses overflow, its label must disclose the narrower population. Quietly expanding the final interval would change the computation rather than explain it.

A density is another quantity again. A density-normalized histogram is not a record-count table, and unequal bin widths require care when interpreting heights. Preserve whether values were counts, weighted sums or densities, together with units and range. The example uses counts only, so no area or probability conclusion is being drawn.

Test an edge before accepting a coverage number

A receiving fixture should include a value below low, at low, on an internal edge, at high and above high. Record the expected bucket or exclusion for each, then run that fixture through the actual consumer. Keep comparison tolerance and prior rounding explicit when real measured values lie near an edge; a display rounded to 20 is not proof the stored value equals 20.

Save eligible input count, missing/invalid count, all bin edges, endpoint convention, below/above-range counts, weighting, output normalization and method/version. These fields allow a reviewer to reproduce the denominator instead of inferring it from a chart. If two reports still disagree, inspect their eligible populations and transformations before changing the interval rule.

The completed boundary fixture explains one apparent count loss without claiming an extraction error or choosing a universal histogram method. Use it to agree on a receiving summary and to retain any intentionally excluded observations. It supplies no distributional fit, acceptable operating threshold or evidence of buyer demand for the underlying archive.

Tools for this decision

Data inventory builder →Diligence question builder →