Class Width Calculator
Five classes over a range of 46 points gives a class width of 10. Divide 46 by 5 to get 9.2, then round up so no score lands on a boundary. Starting at 52, the classes begin at 52, 62, 72, 82 and 92, and the last one ends at 102.
| Class width | |
| Range (largest minus smallest) | |
| Exact width (range over classes) | |
| Class starts | |
| Last class ends at | |
| Class count suggestions | |
Enter the smallest and largest values plus the number of classes. Every class uses the same width, and the last one ends at or above the largest value. All calculations run in your browser and no data is uploaded.
Enter the lowest and highest values in your data plus the number of classes you want. The tool returns the range, the exact width, the rounded-up width and every class start.
Key takeaways
- Class width = (largest value - smallest value) / number of classes, then round up
- A range of 46 split into 5 classes is 9.2, which rounds up to 10
- OpenStax rounds 1.76 up to 2 for its 59.95 to 74.05 example with 8 bars
- Five to 15 classes is the usual working range; 150 values suggests about 12
- The last class should end at or above the largest value, never below it
On this page
What class width controls in a histogram
A histogram splits the range of a data set into equal-sized bins and counts how many values fall in each one. The NIST/SEMATECH e-Handbook of Statistical Methods describes the common form as splitting the range into equal-sized bins, called classes, and counting the points in each bin. The class width is the width of a single bin along the horizontal axis.
That one number sets how much detail the chart shows. Narrow bins separate nearby values but leave gaps and a jagged outline when the sample is small. Wide bins smooth the shape but can hide a second peak or a cluster near one end. OpenStax's Introductory Statistics 2e suggests 5 to 15 classes for most data sets, which is why the class count is an input on this page rather than something the tool decides for you.
Three inputs drive the whole calculation: the smallest value, the largest value, and the number of classes you want. Everything else, including the rounding step that most people get wrong, follows from those three.
The class width formula and the round-up rule
The formula is class width equals the range divided by the number of classes, where the range is the largest value minus the smallest. OpenStax Introductory Statistics 2e, section 2.2, gives the same rule and adds the step that matters: round the result up. In its worked case, 74.05 minus 59.95 equals 14.1, and 14.1 divided by 8 equals 1.76, which the text rounds up to 2 units per bar.
Coverage is the reason for rounding up. A width of 1.76 leaves the eighth class ending at 74.03, just short of the largest value at 74.05, so that observation has nowhere to go. Rounding up also keeps data values off the shared edges between classes, which is the second reason OpenStax gives for the rule.
One exception is worth knowing. When the division lands on a whole number, the width can stay as it is. A range of 42 split into 6 classes gives exactly 7, and the last class then ends on the largest value. Some instructors still add a unit so a visible gap remains, and the width override box on this page covers that case.
Worked example: test scores from 52 to 98
Suppose 30 students scored between 52 and 98 on an exam and you want five classes. The range is 98 minus 52, which is 46 points. Divide 46 by 5 and you get 9.2 points. Round up and every class is 10 points wide.
Starting at 52, the classes cover 52 to 61, 62 to 71, 72 to 81, 82 to 91, and 92 to 101. The top score of 98 sits in the last class with three points of room to spare. Nothing falls on an edge, and no score is left outside the chart.
| Class | Class limits | Midpoint |
|---|---|---|
| 1 | 52 to 61 | 56.5 |
| 2 | 62 to 71 | 66.5 |
| 3 | 72 to 81 | 76.5 |
| 4 | 82 to 91 | 86.5 |
| 5 | 92 to 101 | 96.5 |
Each midpoint is the average of its two limits. For the first class, 52 plus 61 is 113, and 113 divided by 2 is 56.5. The midpoints then climb by 10, the same as the width, ending at 96.5.
A second case: the 59.95 to 74.05 data
The OpenStax example is a useful check because the numbers are not tidy. The smallest value is 59.95, the largest is 74.05, and the text asks for eight bars. The range is 14.1, the exact width is 1.76, and the rounded width is 2.
Eight classes of 2 units each run from 59.95 to 75.95, which clears the maximum by 1.9 units. That spare room at the top is normal. The last class almost always extends past the largest observation, and that is fine as long as every class uses the same width.
| Class | Lower edge | Upper edge |
|---|---|---|
| 1 | 59.95 | 61.95 |
| 2 | 61.95 | 63.95 |
| 3 | 63.95 | 65.95 |
| 4 | 65.95 | 67.95 |
| 5 | 67.95 | 69.95 |
| 6 | 69.95 | 71.95 |
| 7 | 71.95 | 73.95 |
| 8 | 73.95 | 75.95 |
Enter these numbers with a width of 1.76 instead and the eight classes end at 74.03, which leaves 74.05 with no class. That failure is exactly what the round-up rule prevents, and it is why the rule is stated as a rule rather than a preference.
Choosing the number of classes
OpenStax gives two starting points: 5 to 15 classes for readability, and the square root of the number of observations as a rough count. With 150 values, the square root is about 12.25, which rounds to 12 classes.
Sturges' rule, published by Herbert Sturges in 1926, is the other common choice. The number of classes equals 1 plus 3.322 times the base-10 logarithm of the sample size. For 40 observations, the log of 40 is about 1.602, so 3.322 times 1.602 equals 5.32, and adding 1 gives 6.32 classes, which rounds up to 7.
NIST's Dataplot documentation lists further class-width rules, including David Scott's rule based on the sample standard deviation and an interquartile-range rule, for anyone who needs something beyond range over classes. Both simple rules above are starting points, not laws. Skewed data often need a few more classes to show the tail, and a small sample needs fewer so that no bar sits empty. Enter a sample size and the calculator shows both suggestions, then leaves the final choice to you.
Class limits, boundaries, and midpoints
Class limits are the smallest and largest values that belong in a class, written at the precision of the data. For whole-number test scores, the first class runs from a limit of 52 to a limit of 61.
Class boundaries close the gap between neighboring classes. They sit half a unit below the lower limit and half a unit above the upper limit, so the first class is bounded by 51.5 and 61.5, and the second by 61.5 and 71.5. That shared edge is what makes the bins continuous along the axis.
The midpoint, also called the class mark, is the average of the two limits. For 52 and 61 the midpoint is 56.5. Midpoints matter when you only have grouped data and need a mean: multiply each midpoint by its frequency, add the products, and divide by the total count.
| Class limits | Class boundaries | Midpoint |
|---|---|---|
| 52 to 61 | 51.5 to 61.5 | 56.5 |
| 62 to 71 | 61.5 to 71.5 | 66.5 |
| 92 to 101 | 91.5 to 101.5 | 96.5 |
Width stays the same whether you measure it with limits or boundaries. The 52 to 61 class is 10 units wide as limits and 10 units wide as boundaries, from 51.5 to 61.5.
Five mistakes that spoil a histogram
- Rounding down, or not rounding at all. A width of 9.2 across five classes puts the top score of 98 exactly on the final edge, where the count becomes a judgment call.
- Mixing widths. One 5-unit class beside four 10-unit classes makes the narrow bar look tall and distorts the shape.
- Starting the first class above the smallest value. The lowest observation then has no bin, and the chart silently drops it.
- Using too many classes for a small sample. Twelve classes for 20 values averages 1.67 observations per bar, so most bars sit empty and the shape is noise.
- Reporting a width without units. A width of 10 means nothing until you say 10 points, 10 dollars, or 10 minutes.
The first mistake is the one to watch, because it can pass a quick eyeball test. A chart with the largest value on the last edge looks complete until you try to count that value.
What the calculator returns
The defaults are the exam score case: 52, 98, and 5 classes. The tool returns the range, the exact width, the rounded width, and the list of class starts.
| Field | Value for the default case |
|---|---|
| Smallest value | 52 |
| Largest value | 98 |
| Number of classes | 5 |
| Range | 46 points |
| Exact width | 9.2 points |
| Class width after rounding up | 10 points |
| Class starts | 52, 62, 72, 82, 92 |
| Last class ends at | 102 |
Change any input and the boundary list rebuilds. If the last class ends below the maximum, the results area says so, because that means the chosen width cannot cover the data. The override box accepts a width you supply yourself, which is useful when a course or a report requires one exact interval.
Frequently asked questions
What is class width?
Class width is the size of one bin in a histogram, measured along the horizontal axis. A class from 52 to 61 with a gap to 62 has a width of 10.
How do you calculate class width?
Subtract the smallest value from the largest, then divide by the number of classes and round up. For scores from 52 to 98 in 5 classes, 98 minus 52 is 46, 46 divided by 5 is 9.2, and the width is 10.
Do you always round class width up?
OpenStax says to round up, even when normal rounding would go down, because a short width can leave the largest value outside the last class. Its own example turns 1.76 into 2.
How many classes should a histogram have?
OpenStax suggests 5 to 15 classes for clarity. The square root of the sample size is a common starting point, so 150 values point to about 12 classes.
What is Sturges' rule?
It sets the class count at 1 plus 3.322 times the base-10 log of the sample size. For 40 observations that is 1 plus 5.32, or 6.32, which rounds up to 7 classes.
What is the difference between class width and class limits?
Width is the span of a class, while limits are its end values. A class with limits of 52 and 61 has a width of 10 once you allow the gap before the next class starts at 62.
Can class width be a decimal?
Yes. The OpenStax example uses a width of 2 on data reported to two decimals, and a width of 1.5 or 0.5 is common for measurements. Round up to the precision you want to report.
Why does my last class stop before the maximum?
The width times the number of classes came out below the range. Five classes of 9 leave the last class ending at 97 when the maximum is 98, so add a class or widen the interval.
What if every value in the data set is the same?
The range is 0, so no width can be computed from it. Report the single value and note that the data have no spread, or use a width of 1 to show one bar.
Is class width the same as bin width?
Yes. NIST calls the intervals bins and statistics courses call them classes, but the width is the same measurement either way.
How do I find the range?
Subtract the smallest observation from the largest. With a low score of 52 and a high score of 98, the range is 46.
Does class width change the shape of a histogram?
It does. A width of 5 on the exam data would produce 10 bars and show gaps that a width of 10 hides, while a width of 20 would merge the two lower clusters into one bar.
What is a class midpoint?
The midpoint is the average of a class's limits. For the class from 52 to 61, 52 plus 61 is 113, and half of that is 56.5.
Spotted a wrong number or a broken result?
More Math tools
Fee schedules, rates and rules change without notice. Always confirm important figures with the official source before you rely on them.