Histogram Bin Calculator
Histogram bin counts by three rules.
What it does
Histograms live or die on bin count: too few bars bury modes, too many shred signal into noise. Three classic rules turn the observation count into starting counts.
The tool above takes the observation count. It returns Sturges, square root, and Rice bin counts.
The default 100 values gives 8 by Sturges with 10 each by root and Rice. The 30 case reads 6, 6, 7, and 1000 reads 11, 32, 20.
NIST histogram guidance teaches Sturges with root alternatives, and LibreTexts statistics adds Rice for skewed sets. Widths follow by dividing the data range.
Rules start the search; eyes finish it. Empty bins mean fewer, hidden second humps mean more, and categories skip bin math entirely for one bar each.
How to use
- Type the observation count.
- Read Sturges first.
- Read square root beside it.
- Read Rice last.
- Divide range for width.
- Redraw and judge shape.
Formula
- n
- Observation count, 5 plus.
- Sturges
- Classic normal data rule.
- Rice
- Cube root rule for skew.
NIST/SEMATECH e-Handbook histogram guidance carries Sturges with square root alternatives for bin starts. LibreTexts statistics mirrors Sturges and Rice rules for class counts. Counts here size bins; widths divide the data range by the count.
Worked example
Example: 100 values
Default: 100 observations.
- Data: 100 observations.
- Sturges: 1 + 3.322 x log10(100) = 7.64, up to 8.
- Root: root(100) = 10 bins.
- Rice: 2 x cube root(100) = 9.28, up to 10.
- Check: 100 / 8 = 12.5 per bin.
- Tool shows 8 bins, 10 bins, 10 bins.
Reference table
| n | Sturges | Root | Rice |
|---|---|---|---|
| 100 | 8 | 10 | 10 |
| 30 | 6 | 6 | 7 |
| 1000 | 11 | 32 | 20 |
| 50 | 7 | 8 | 8 |
Limits
- Counts only, not widths.
- Rules assume continuous data.
- Tiny samples wobble.
- Skew bends every rule.
Common mistakes
- One rule for all shapes.
- Binning categories by math.
- Ignoring empty bins.
- Forgetting width anchoring.
- Trusting defaults blindly.
Try it yourself
Quick checks. Answers sit tucked under each question.
30 observations?
Sturges 6, root 6, Rice 7.
1000 observations?
Sturges 11, root 32, Rice 20.
3 observations?
Under 5 starves bin rules: enter 5 plus observations.
Questions
Three rules?
Sturges 1+3.322 log10 n, square root of n, Rice 2n^1/3, each rounded up. Try all three.
Which rule wins?
Sturges for small clean data, root for quick looks, Rice for skewed larger sets.
Bin width from count?
Divide range by bins for width, then anchor edges on round numbers.
Judge the histogram?
Yes, empty bins signal too many; lumpy shapes signal too few. Adjust and redraw.
Categories?
No, rules assume continuous data. Categories need one bar each, not math.
Freedman Diaconis?
Freedman Diaconis uses IQR for width and needs the data itself, not just n.