Histogram Hub

How to Choose the Number of Bins

Why the bin count matters

The number of bins is the single biggest choice in a histogram. Too few and you smooth away real features; too many and random noise looks like structure. There is no one right answer, so it helps to know the standard rules and try a couple.

The rules, and when to use them

  • Sturges: k = ceil(log2 n) + 1. The classic default. Good for small, roughly bell-shaped datasets. It tends to use too few bins once n gets large.
  • Freedman-Diaconis: bin width = 2 x IQR x n^(-1/3). Uses the interquartile range, so outliers do not blow up the bin width. The best general-purpose choice for skewed or messy data.
  • Scott: bin width = 3.49 x standard deviation x n^(-1/3). Assumes the data is close to normal. Slightly wider bins than Freedman-Diaconis on clean data.
  • Rice: k = ceil(2 x n^(1/3)). A simple alternative to Sturges that gives more bins for large samples.
  • Square root: k = ceil(sqrt n). The rule most spreadsheets fall back to. Quick, but rarely the best.

A practical routine

Start with the default (Sturges). If the chart looks blocky or hides detail, switch to Freedman-Diaconis. If your data is clean and bell-shaped, Scott is fine. The histogram maker lets you flip between all of these instantly, so you can watch the shape and stop when the picture is honest: enough bins to show the real structure, few enough that you are not reading noise.

The two mistakes to avoid

Too few bins hides skew, gaps, and second peaks. Too many bins turns a smooth distribution into a spiky mess where every bar is one or two points. When two methods disagree a lot, the truth is usually between them.

Frequently asked questions

How many bins should a histogram have?
A common starting point is Sturges rule, ceil(log2 n) + 1. For skewed data or data with outliers, Freedman-Diaconis usually gives a better result. Try two or three and keep the clearest.
What is the best bin-width rule?
Freedman-Diaconis is the best general-purpose rule because it uses the interquartile range and resists outliers. Scott is good when the data is close to normal.
Is more bins always better?
No. Too many bins turns random noise into fake peaks, with most bars holding just one or two points. The goal is enough bins to show real structure and no more.