How class width is calculated
Class width is the size of each interval (class or bin) in a grouped frequency distribution or histogram. It tells you how wide each bar should be so that, taken together, the classes cover every value in your dataset. The formula is:
Class width = (Maximum value − Minimum value) ÷ Number of classes
The difference (maximum − minimum) is the range of the data. Dividing the range by the number of classes you want gives the raw width. That raw value is then rounded up to a convenient number — usually the next whole number for integer data, so the intervals are easy to read and still span the entire range.
Worked example
Suppose exam scores run from a minimum of 43 to a maximum of 98, and you want 5 classes. The range is 98 − 43 = 55. Dividing gives 55 ÷ 5 = 11, so the class width is 11. Your classes would be 43–53, 54–64, 65–75, 76–86, and 87–97 (using a width of 11 for each). If instead the maximum were 96, the range would be 53, and 53 ÷ 5 = 10.6, which rounds up to a class width of 11.
Why round up rather than down
Rounding up guarantees the classes cover the full range. With a width of 10.6 rounded down to 10, five classes span only 5 × 10 = 50 units — less than the 53-unit range — so the highest data values would fall outside the last class. Rounding up to 11 gives 5 × 11 = 55 units of coverage, comfortably enclosing every observation.
Choosing the number of classes
Most textbooks recommend between 5 and 20 classes. A common formula is Sturges' rule: number of classes ≈ 1 + 3.322 × log₁₀(n), where n is the sample size. For example, with n = 50 data points, Sturges' rule gives 1 + 3.322 × log₁₀(50) ≈ 1 + 3.322 × 1.699 ≈ 6.6, so you would use about 6 or 7 classes. Too few classes flatten the distribution's shape; too many produce a spiky histogram full of near-empty bins.