Class Width Calculator
Calculate optimal class width and intervals for frequency distributions using Sturges', Scott's, Freedman-Diaconis, Square Root, and Rice rules.
About
Choosing the wrong class width collapses distinct data patterns into noise or fragments them into meaningless spikes. A histogram with too few bins hides bimodality; too many bins create random jaggedness that misleads interpretation. This calculator determines optimal class width h and number of classes k from raw ungrouped data using five established rules: Sturges' formula, Scott's normal reference rule, the Freedman-Diaconis estimator, the Square Root choice, and Rice's rule. Each method makes different assumptions about the underlying distribution. Sturges assumes approximate normality. Freedman-Diaconis is robust against outliers because it relies on the interquartile range IQR rather than standard deviation σ. The tool parses your raw observations, computes all five widths simultaneously, builds a grouped frequency table with absolute, relative, and cumulative frequencies, and renders a histogram. Note: all rules are asymptotic approximations. For sample sizes below 30, results should be treated as rough guides, not definitive answers.
Formulas
The calculator determines the number of classes k and class width h from n observations spanning a range R = xmax − xmin. Five rules are evaluated simultaneously.
Sturges' Rule
k = ⌈1 + 3.322 ⋅ log10(n)⌉ , h = RkScott's Rule
h = 3.49 ⋅ s ⋅ n−13 , k = ⌈Rh⌉Freedman-Diaconis Rule
h = 2 ⋅ IQR ⋅ n−13 , k = ⌈Rh⌉Square Root Rule
k = ⌈√n⌉ , h = RkRice Rule
k = ⌈2 ⋅ n13⌉ , h = RkWhere n = number of observations, R = range (xmax − xmin), s = sample standard deviation (Bessel-corrected), IQR = interquartile range (Q3 − Q1), h = class width, k = number of classes, and ⌈ ⌉ denotes the ceiling function.
Reference Data
| Rule | Formula for Classes / Width | Assumption | Best For | Weakness |
|---|---|---|---|---|
| Sturges (1926) | k = 1 + 3.322 ⋅ log10(n) | Normal distribution | Small to moderate n (< 200) | Under-bins for large or skewed data |
| Scott (1979) | h = 3.49 ⋅ σ ⋅ n−1/3 | Normal distribution | Continuous, roughly symmetric data | Sensitive to outliers via σ |
| Freedman-Diaconis (1981) | h = 2 ⋅ IQR ⋅ n−1/3 | None (nonparametric) | Skewed data, outlier-heavy sets | May over-bin if IQR is very small |
| Square Root | k = √n | None | Quick estimation, Excel default | No theoretical optimality |
| Rice (1944) | k = 2 ⋅ n1/3 | None | Large datasets | Tends to over-bin for small n |
| Manual | User-defined k | Domain knowledge | Regulatory or publication standards | Requires expertise |
| Common sample size benchmarks | ||||
| n = 30 | Sturges: 6, √: 5, Rice: 6 | Minimum for CLT approximation | ||
| n = 100 | Sturges: 8, √: 10, Rice: 9 | Typical classroom dataset | ||
| n = 500 | Sturges: 10, √: 22, Rice: 16 | Survey-scale data | ||
| n = 1000 | Sturges: 11, √: 32, Rice: 20 | Large-sample analytics | ||
| n = 10000 | Sturges: 15, √: 100, Rice: 43 | Big-data; Sturges notably under-bins | ||
| Descriptive statistics used internally | ||||
| Range | R = xmax − xmin | Spread of data | ||
| Mean | = 1n n∑i=1 xi | Arithmetic average | ||
| Std Dev (σ) | s = √n∑i=1(xi − )2n − 1 | Sample standard deviation (Bessel-corrected) | ||
| IQR | IQR = Q3 − Q1 | Middle 50% spread, outlier-resistant | ||
| Q1 (25th percentile) | Linear interpolation at rank 0.25(n + 1) | Lower quartile boundary | ||
| Q3 (75th percentile) | Linear interpolation at rank 0.75(n + 1) | Upper quartile boundary | ||