Building a frequency table
- Find the range: maximum − minimum.
- Choose the number of classes: usually 5 to 20. Sturges (1926) proposed k ≈ 1 + log₂n for n observations (about 8 when n = 100).
- Choose the class width: range ÷ number of classes, rounded up to a convenient value. Classes must not overlap and must cover all data (for example, 60 or more and under 70).
- Count frequencies: count the observations in each class and record the class mark (the midpoint of the interval).
Relative and cumulative frequency
Relative frequency is frequency divided by the total number of observations and is used to compare groups of different sizes. Cumulative frequency adds frequencies from the first class up to a given class; its graph (an ogive) lets you roughly read off the median and percentiles.
Histograms vs bar charts
A histogram represents intervals of continuous quantitative data, so its bars touch and the area of each bar is proportional to frequency (or proportion). When class widths differ, the vertical axis should show density (relative frequency ÷ class width) rather than frequency. A bar chart, by contrast, represents categories of categorical (qualitative) data, so its bars are separated and their order can be changed. The term "histogram" is credited to Karl Pearson, who used it in an 1891 lecture.
Rules for choosing bin width
Too few classes blur the features of a distribution; too many make it jagged. Sturges' rule assumes roughly normal data and tends to give too few classes for large data sets. Scott (1979) proposed a width based on the standard deviation (about 3.49·s·n−1/3), and Freedman and Diaconis (1981) proposed a width based on the interquartile range (2·IQR·n−1/3) that is less sensitive to outliers.
Reading the shape
A histogram shows whether data are symmetric or skewed to the right (positive) or left (negative), whether there is one peak or more, and whether there are outliers. In right-skewed distributions such as income, the mean is larger than the median. The same data can look different depending on bin width and starting point, so it helps to draw the histogram with several widths.
References
- Pearson, K. (1895). Contributions to the mathematical theory of evolution. II. Skew variation in homogeneous material. Philosophical Transactions of the Royal Society of London A, 186, 343-414.
- Sturges, H. A. (1926). The choice of a class interval. Journal of the American Statistical Association, 21(153), 65-66.
- Scott, D. W. (1979). On optimal and data-based histograms. Biometrika, 66(3), 605-610.
- Freedman, D., & Diaconis, P. (1981). On the histogram as a density estimator: L2 theory. Zeitschrift für Wahrscheinlichkeitstheorie und verwandte Gebiete, 57(4), 453-476.