Choosing Histogram Bins

A Mathematical Starting Point

November 16, 20255 min read

Freedman Diaconis Output

Paste your data to compute the Freedman Diaconis bin width. The rule suggests a target width, which is converted into a rounded bin count, and the range from minimum to maximum is then split into equal width bins.

Histogram binning is not decorative. It decides whether the reader sees a signal or a blocky shape or a wall of noise. The Freedman Diaconis rule provides a simple width that works well for many data sets.

The Freedman Diaconis rule

The rule defines a bin width h. It uses the spread of the middle half of the data and the size of the sample:

h=2IQRn1/3h = \frac{2 \cdot IQR}{n^{1/3}}

Where:

  • IQR is the interquartile range. It is the distance between the 25th percentile Q1Q_1 and the 75th percentile Q3Q_3. It measures the spread of the central half of the data and is resistant to extreme values.
  • n is the number of observations in the data set. The term n1/3n^{1/3} shrinks the width as the sample grows, which allows more detail when you have more data.

The number of bins k follows from the width:

k=max(x)min(x)hk = \frac{\max(x) - \min(x)}{h}

That is what the tool above computes.

Why it is a good starting point

  • IQR resists outliers, so the width is not distorted by extreme values.
  • n1/3n^{-1/3} scales the width smoothly as you gain more data.
  • The result usually avoids noisy oversplitting and oversmoothing.

Where it struggles

  • Very small samples, where quartiles move around too much.
  • Identical or nearly identical values, where IQR becomes zero.
  • Long and sparse tails, where the range widens but adds little shape.
  • Data with several peaks, where one global width may hide structure.

When the rule breaks, adjust by eye until you can balance noise and the shape of the data.

Present with Data Playbook

Discover Your Partner in Communicating Clearly with Data

Chartosaur