Histogram Bins Calculator
Find the optimal number of histogram bins and bin width by three rules — Sturges, Scott, and Freedman-Diaconis — from your data.
Result
How to use this calculator
- Paste your dataset, separated by commas, spaces, or new lines.
- Read the suggested bin counts from Sturges, Scott, and Freedman-Diaconis.
- Use Freedman-Diaconis for skewed data or when outliers are present.
- Adjust the chosen bin count visually until the histogram shape is clear.
About this calculator
Choosing the number of bins for a histogram is a balance: too few bins hide the shape of the distribution, too many make it noisy. Several rules formalize the choice. Sturges' rule, k = ⌈log₂n + 1⌉, is simple and works for small, roughly bell-shaped datasets but tends to use too few bins for large samples. Scott's rule sets the bin width from the standard deviation and sample size, assuming the data is approximately normal. The Freedman-Diaconis rule uses the interquartile range instead of the standard deviation, which makes it robust to outliers and skew. This calculator computes all three from your pasted data, reporting both the bin count and bin width for each, so you can pick the one that best matches your data and visualize accordingly.
How it works — the formula
Sturges: k = ⌈log₂ n + 1⌉
Scott: h = 3.49 · s · n^(−1/3), k = ⌈range / h⌉
Freedman-Diaconis: h = 2 · IQR · n^(−1/3), k = ⌈range / h⌉Sturges counts bins directly from sample size; Scott and Freedman-Diaconis derive a bin width from spread and sample size, then divide the range by it.
Worked examples
- Inputs:
- data=4,8,15,16,23,42,11,19,27,33,5,9
- Output:
- Sturges ⌈log₂12+1⌉ = 5 bins
- Inputs:
- 100 values
- Output:
- Sturges = ⌈6.64+1⌉ = 8 bins
- Inputs:
- 1000 values
- Output:
- Sturges = ⌈9.97+1⌉ = 11 bins
Limitations
- Sturges under-bins large datasets; Scott assumes normality.
- Freedman-Diaconis can give very many bins for tight IQR with wide range.
- All are guidelines — final bin count is a visualization judgment.
Bin-count rules are heuristics; always sanity-check the resulting histogram.
Frequently asked
How many bins should a histogram have?+
What is Sturges' rule?+
How does Scott's rule differ from Freedman-Diaconis?+
Why does bin width scale with n^(−1/3)?+
Which rule should I use?+
Do I round bins up or down?+
Related calculators
More tools you might like
Hand-picked tools that pair well with this one — same audience, same intent.
Paste a list of numbers to get the mean, median, mode, range, count, and sum — the core measures of central tendency.
Compute sample and population standard deviation and variance from a pasted list of numbers, with the mean and formulas shown.
Find Q1, Q2 (median), Q3, the interquartile range, and outliers using the 1.5×IQR rule from a pasted dataset.
C(n, r) = n! / (r!(n−r)!). Number of ways to choose r items from n where order doesn't matter.
P(n, r) = n! / (n−r)!. Number of ways to arrange r items from n where order matters.
Gross, operating, and net margin — three standard profitability ratios.