Histogram Bin Count and Width
The number, width and boundaries of intervals used to partition a numerical range in a histogram.
Two decisions determine the resolution of a histogram: how many intervals to construct and where their edges lie. Given sample minimum x_min, maximum x_max and range R = x_max − x_min, the nominal width of k equal-width bins is h = R/k. Extending the plotting limits beyond the observed extrema changes the actual edge layout.
Edges must define a partition
Under [a_i,a_{i+1}), a boundary belongs to the interval on its right. An implementation may include the final right endpoint. Without a stated convention, boundary observations can be double-counted or omitted. The midpoint is (a_i+a_{i+1})/2; missing or out-of-range observations need separate accounting.
For min=2, max=18 and four bins, R=16 and h=4. One complete partition is [2,6), [6,10), [10,14) and [14,18]. Starting the edges at 0 instead produces different intervals, even when the same data are plotted.
Estimating a count or estimating a width
Sturges' rule and Rice's rule primarily produce bin-count estimates from n. Freedman–Diaconis and Scott's rule first estimate h, implying roughly k ≈ R/h. Doane's rule adjusts the count for skewness. Integer rounding, edge expansion and the handling of zero spread differ across implementations.
Sample size alone does not reveal whether a distribution has narrow peaks, heavy tails or sparse regions. Wide bins obscure structure; narrow bins amplify sampling variation. A statistical histogram and a frequency table are alternative representations of the same interval counts.