Class Width Calculator
Find the class width for a frequency distribution or histogram and get the full table of class boundaries in one step. Work from a raw data set or straight from the minimum, maximum, and desired number of classes — the calculator applies the textbook rule of dividing the range by the class count and rounding up.
Two Ways to Use This Calculator
Data set mode: paste your raw values; the tool finds the minimum and maximum itself, builds the classes, and tallies how many values land in each one.
Range mode: when the exercise already states the minimum, maximum, and number of classes, enter just those three numbers and skip the data entry.
Choosing the Number of Classes
- Most homework problems specify k directly; if not, 5 to 20 classes is the standard working band.
- Sturges' rule gives a defensible default from the sample size alone — the calculator reports it whenever you provide a data set.
- Fewer classes smooth the histogram and hide detail; more classes expose detail but scatter the counts thin.
Enter numbers separated by commas, spaces, or line breaks
Related Calculators
Mean, Median, Mode Calculator
Find mean, median, mode, range, sum, and count with a full step-by-step solution.
Interquartile Range Calculator
Find the IQR with Q1, Q3, the median, and 1.5 × IQR fences via the median-split method.
Percentile Calculator
Find the value at any percentile or a value's percentile rank using linear interpolation.
The Class Width Formula, and Why You Round Up
Class width answers a packing question: how wide must each of k equal intervals be to hold everything from the minimum to the maximum?
Class width = ⌈(max − min) / k⌉ (round up)
Rounding up is not cosmetic. If you round the division down — or even keep the exact decimal and truncate limits later — the k classes span less than the full range and the largest values fall off the end of the table. Rounding up guarantees k × width ≥ range, so the final class always reaches past the maximum. The cost is harmless slack: the last class may extend beyond the largest observation, which affects nothing but the appearance of the table. Rounding up to a convenient number (10 rather than 9.4) buys tidy boundaries for the same guarantee.
Sturges' Rule and Other Ways to Pick k
When the number of classes is yours to choose, Sturges' rule is the classic starting point, tying k to the sample size:
k = 1 + 3.322 × log₁₀(n)
The constant 3.322 is 1/log₁₀(2), so the rule is really k = 1 + log₂(n): one extra class each time the sample doubles. For n = 20 it suggests 5.32 → 6 classes; for n = 1000, about 11. Alternatives exist — the square-root rule k = √n and Rice's rule k = 2n^(1/3) both allow more classes for large samples, where Sturges tends to over-smooth. All three are starting points rather than laws: build the table, look at the histogram, and adjust k until the shape of the data shows without the counts scattering thin.
From Class Width to a Frequency Distribution
The class width is step two of the standard recipe for grouping data. Start the first class at the minimum (or at a convenient number just below it), add the width repeatedly to generate each lower boundary, and tally how many observations land in each interval — exactly the table this calculator produces. To keep every value in exactly one class, treat each interval as including its lower boundary but not its upper one, with the final class closed on both ends; a value of 52 with a boundary at 52 belongs to the class that starts there, not the one that ends there.
The finished frequency distribution is the skeleton of a histogram: one bar per class, bar height equal to the count. Grouping trades detail for readability, so summary statistics quoted from grouped data are approximations — compute the exact mean and spread from the raw values with the descriptive statistics calculator before the grouping, and use the five number summary calculator when a positional summary tells the story better than bars.
Common Mistakes When Building Classes
- Rounding the width down: the classes stop short of the maximum and the largest values have no home — the single most common error on homework.
- Double-counting boundaries: classes written as 10–20 and 20–30 must agree on where 20 belongs. State the convention (this page puts boundary values in the class that starts with them).
- Unequal widths: mixing widths makes bar heights incomparable; a histogram then needs frequency densities instead of raw counts.
- Leaving gaps: each upper boundary must equal the next lower boundary, or values in the gap vanish from the table.
- Extreme k: three classes flatten every feature of the distribution; forty classes with twenty data points put most counts at zero or one.
Worked Example: Twenty Exam Scores in Six Classes
An instructor has 20 exam scores with a minimum of 42 and a maximum of 98, and wants k = 6 classes for a histogram:
- Range: 98 − 42 = 56.
- Divide by k: 56 ÷ 6 = 9.33.
- Round up: class width = 10.
- Generate boundaries from the minimum: 42–52, 52–62, 62–72, 72–82, 82–92, 92–102.
- Check coverage: the first class starts at 42 (the minimum) and the last extends to 102, past the maximum of 98 — every score has a class.
Had the instructor rounded down to a width of 9, six classes would end at 42 + 54 = 96, and the two students who scored above 96 would fall outside the table. The choice of k = 6 also matches Sturges' rule here: 1 + 3.322 × log₁₀(20) = 5.32, rounded up to 6 — a reassuring sign the histogram is neither over- nor under-smoothed for a class of twenty.
Frequently Asked Questions
Why must the class width be rounded up instead of to the nearest number?
Because coverage is the whole point. Rounding 9.33 to 9 leaves k classes spanning only 54 units of a 56-unit range, stranding the largest values outside the table. Rounding up guarantees the classes reach past the maximum; the only side effect is a little slack after the largest value, which is harmless.
What happens when the range divides evenly by the number of classes?
The ceiling function changes nothing - a range of 60 across 6 classes gives a width of exactly 10 - and the last class ends exactly at the maximum. Since this calculator's final class includes its upper boundary, the maximum still has a home. Some textbooks prefer to widen the classes by one unit in this situation so the maximum falls strictly inside; both conventions appear in courses, so follow whichever your materials use.
My data has decimals. Is a whole-number class width still right?
The rounded-up whole-number width always covers the data; the question is resolution. For values like 1.2 to 4.7, a width of 1 produces sensible classes, but for data spanning only 0.3 units the integer rule is too coarse. In that case divide the range by k and round up at a convenient decimal (0.05, 0.1) instead - the covering logic is identical, just at a finer grain.
Do all classes have to be the same width?
For a standard frequency distribution and histogram, yes - equal widths make bar heights directly comparable as counts. Unequal widths are legitimate only in special situations (open-ended income brackets, for example) and then the histogram must plot frequency density (count divided by width) rather than raw frequency to avoid a distorted picture.
Should a boundary value like 52 count in the class ending at 52 or starting at 52?
Convention decides, and the table breaks if the two classes disagree. This calculator uses left-closed intervals: each class contains its lower boundary and excludes its upper one, except the final class, which includes both ends. So 52 belongs to the class starting at 52. Many texts avoid the issue by choosing class limits between the possible data values, such as 41.5 to 51.5 for whole-number scores.