Probability & Statistics · Histogram

Histogram

A histogram shows how numerical data are spread: the number line is cut into equal bins, and each bar counts the values that fall in its bin. Change the bin width and the starting point and watch the same data take different shapes.

Histogram in this visualization

A histogram shows how a set of numbers is spread out. The number line is cut into bins of equal width ww starting at oo, the bins [o+kw, o+(k+1)w)[o + kw,\ o + (k+1)w), and each bar counts the values that fall in its bin. Each bin includes its left edge and not its right one, so a value lying exactly on an edge belongs to the bin on its right. A bin with no values gets no bar; the bars touch, because the bins cover the line without gaps. Under the axis each value is a short tick, so the data behind every bar stay in view.

Why the same data can look different

A histogram depends on two choices that have nothing to do with the data. Wide bins pool values from different places, so a gap between two clusters can be averaged away and two humps become one lump. Narrow bins hold only a few values each, so with a finite sample the local ups and downs are easily driven by sampling variation. Even with the width fixed, moving the starting point regroups the values, and a peak can shift or change height. A feature worth believing should survive several reasonable widths and starting points. Rules of thumb for choosing a width exist, but none is the single correct one.

Count, proportion, density

A bar’s height can be read as a count, as the proportion of all nn values (count ÷ nn), or as a density (proportion ÷ ww). On the count and proportion scales, doubling the width roughly doubles every bar, so bars from histograms with different widths cannot be compared directly. On the density scale the area of each bar is the proportion of values in it and the total area is 1, so across different widths a height means the same thing: the proportion of values per unit length. How exact bin probabilities lead to a density curve is the subject of probability density function.

Controls

  • Drag along the bars, or the triangle under the axis, to move the bin start; click a bar to read it.

Related