Lelifi·tools

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.

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.

By the Lelifi editors ·

Key takeaways

Five classes over a 46 point rangeRange = 98 - 52 = 46 pointsExact width = 46 / 5 = 9.2 pointsRounded-up width = 10 pointsClass starts: 52, 62, 72, 82, 92Last class ends at 102, above the max of 98Round up before you build the bins, or the largest value can land on an edge.
The exam score case in four steps: range 46, exact width 9.2, rounded width 10, and a last class ending at 102.
Five equal classes, width 10, covering scores 52 to 9852 to 6162 to 7172 to 8182 to 9192 to 10198 lands herecount
Five equal classes of width 10 from 52 to 101. The top score of 98 falls in the last class, not on an edge.
On this page
  1. What class width controls in a histogram
  2. The class width formula and the round-up rule
  3. Worked example: test scores from 52 to 98
  4. A second case: the 59.95 to 74.05 data
  5. Choosing the number of classes
  6. Class limits, boundaries, and midpoints
  7. Five mistakes that spoil a histogram
  8. What the calculator returns

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.

ClassClass limitsMidpoint
152 to 6156.5
262 to 7166.5
372 to 8176.5
482 to 9186.5
592 to 10196.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.

ClassLower edgeUpper edge
159.9561.95
261.9563.95
363.9565.95
465.9567.95
567.9569.95
669.9571.95
771.9573.95
873.9575.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 limitsClass boundariesMidpoint
52 to 6151.5 to 61.556.5
62 to 7161.5 to 71.566.5
92 to 10191.5 to 101.596.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

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.

FieldValue for the default case
Smallest value52
Largest value98
Number of classes5
Range46 points
Exact width9.2 points
Class width after rounding up10 points
Class starts52, 62, 72, 82, 92
Last class ends at102

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

See all Math tools

Fee schedules, rates and rules change without notice. Always confirm important figures with the official source before you rely on them.