Understanding the frequency table and histogram bins — concept and principle
A frequency table groups numerical data into intervals (bins or classes) and counts how many values fall into each. It is the first step in drawing a histogram and gives a quick picture of where data cluster, how spread out they are and whether the distribution is skewed. Enter your data and either a number of bins or 0 to let Sturges' rule choose.
How it is calculated
- Number of bins k: your value, or Sturges' rule k = ⌈log₂ n⌉ + 1, where n is the number of data values.
- Bin width: w = (maximum − minimum) ÷ k, so the bins exactly span the data range.
- Bin edges: minimum, minimum + w, minimum + 2w, … , maximum.
- Counting: a value x goes into bin number ⌊(x − minimum) ÷ w⌋. Each bin includes its lower edge and excludes its upper edge, except the last bin, which also includes the maximum.
The principle
Too few bins hide the shape of the data; too many leave most bins with zero or one value and turn the histogram into noise. Sturges (1926) reasoned that an ideal bell-shaped histogram resembles binomial coefficients: with k bins the counts would follow C(k − 1, i), whose total is 2^(k − 1). Setting 2^(k − 1) ≈ n gives k ≈ log₂ n + 1. The rule grows slowly, so it works well for small, roughly symmetric samples but uses too few bins for large or skewed data sets.
Worked example
- Data: 12, 15, 11, 19, 22, 15, 18, 25, 14, 16 (n = 10).
- log₂ 10 ≈ 3.32, rounded up to 4, plus 1: k = 5.
- Range 25 − 11 = 14, so w = 14 ÷ 5 = 2.8.
- Edges: 11, 13.8, 16.6, 19.4, 22.2, 25.
- Counts: 11–13.8: 2 (11, 12); 13.8–16.6: 4 (14, 15, 15, 16); 16.6–19.4: 2 (18, 19); 19.4–22.2: 1 (22); 22.2–25: 1 (25).
| Number of bins (0 = Sturges) | Bins |
|---|---|
| 0 | 5 |
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
| 4 | 4 |
| 5 | 5 |
| 6 | 6 |
How to read the result
The tallest bin (the modal class) shows where values concentrate, here 13.8 to 16.6. Counts that trail off to the right, as in this example, indicate right skew. Divide each count by n for relative frequencies (here 20%, 40%, 20%, 10%, 10%), which lets you compare data sets of different sizes. Try a few bin counts: a real feature persists across choices, while an artefact of one choice does not.
Common mistakes
- Drawing conclusions about shape from very few values.
- Comparing histograms of two data sets that use different bin edges.
Frequently asked questions
Why do two adjacent ranges share an endpoint?
The shared value belongs to the higher bin; only the last bin includes its upper edge.
How many bins should I use for 1,000 values?
Sturges gives ⌈log₂ 1000⌉ + 1 = 11; the square-root rule gives about 32. Choose what shows the shape without excess noise.
Is a frequency table the same as a bar chart?
No. Bar charts show separate categories; histograms show adjacent numeric intervals without gaps.
Sources: Sturges, H. A. (1926). Journal of the American Statistical Association, 21(153), 65–66. · Freedman, D. & Diaconis, P. (1981). Zeitschrift für Wahrscheinlichkeitstheorie und verwandte Gebiete, 57, 453–476.