Advertisement
Advertisement
STATISTICS

Class Width Calculator — limits, boundaries and midpoints

Enter the smallest and largest values and the number of classes you want, and get the class width plus the full set of class limits, boundaries and midpoints.

The minimum observation. The first class starts here unless you set a tidier starting point below.
The maximum observation. The last class must reach at least this far.
Most courses use between 5 and 20. Seven is a common default for a few dozen observations.
1 for whole numbers, 0.1 for one decimal place. This sets the gap between class limits and the half-unit shift to boundaries.
The first rule is what most textbooks teach. The second shows the unrounded figure, which usually produces awkward limits.
A tidy starting value such as 10 or 0 reads much better in a report. It must not sit above your smallest value.
Class width
0
 
0
Range (max − min)
0
Unrounded range ÷ classes
First class limits
Last upper limit
Classes:
Working:
Tip: the bars show the width you would get at other class counts. Pick the count that produces a round width, not the other way round — a width of 10 with six classes reads far better than 8.5 with seven.
Advertisement

The class width calculator above works out the width of each class in a grouped frequency table, and then builds the whole set of classes: the stated limits, the true boundaries, and the midpoint of each one. It takes only the smallest value, the largest value and the number of classes you want. It does not need your data, which is the point — this is the calculation you do before you have tabulated anything, and it is the one textbook exercises usually ask for on its own.

Arb Digital publishes it alongside two related tools that do a different job. Our frequency distribution calculator takes raw data and builds the counted table, and our histogram calculator takes raw data and draws the chart. Both report a class width as one output among many. This page is the reverse: it starts from a range and a class count you have chosen, and its whole output is the class structure — width, limits, boundaries and midpoints — with the limits-versus-boundaries distinction that the other two do not need to make.

What This Class Width Calculator Does

It computes the class width, then lays out every class in the table. For each one it reports three different things that are easy to confuse. The class limits are the values as you would write them in the table, such as 12–23. The class boundaries are the true dividing lines that sit halfway between the upper limit of one class and the lower limit of the next, such as 11.5 to 23.5. The class midpoint, or class mark, is the average of the two limits and is the value that stands in for the whole class when you estimate a mean.

It also lets you set the precision of your data. Whole-number data recorded to the nearest unit produces limits one apart and boundaries half a unit outside them; data recorded to one decimal place produces limits 0.1 apart and boundaries 0.05 outside. That single setting is what makes the boundaries come out correctly, and it is the step most often skipped.

The bar panel recomputes the width at every class count from three to fifteen. That is the most useful thing on the page, because the number of classes is a choice rather than a fact, and the best choice is nearly always the one that produces a round, readable width.

How to Use It

  1. Enter the smallest and largest values in your data. You do not need anything in between.
  2. Choose how many classes you want. Five to twenty is the usual range, and the bars will show you what width each choice produces.
  3. Set the recording precision — 1 for whole numbers, 0.1 for one decimal place, and so on. This is what determines the boundaries.
  4. Optionally set a tidy starting value such as 10 or 0 instead of starting exactly at the minimum.
  5. Read the class table below the grid, and check that the last upper limit reaches your maximum.

The Formula and How It Is Calculated

The familiar formula is class width = range ÷ number of classes, with the range being the largest value minus the smallest. That gives the unrounded figure shown in the second grid item. What almost every course adds — and what trips people up — is that the result is then rounded up, never down, and rounded up even when the division comes out exactly.

Work the default through. The values run from 12 to 89, so the range is 77, and 77 ÷ 7 = 11 exactly. Take the width as 11 and start at 12, and the classes are 12–22, 23–33, 34–44, 45–55, 56–66, 67–77 and 78–88. The last one stops at 88, and the value 89 has nowhere to go. Rounding up to 12 fixes it: 12–23, 24–35, 36–47, 48–59, 60–71, 72–83 and 84–95, which comfortably contains 89.

The reliable way to see this is to work with the inclusive range. With data recorded to the nearest unit p, the classes cover from the first lower limit to that limit plus k×w minus p. Coverage therefore requires w to be at least (range + p) ÷ k, which here is 78 ÷ 7 = 11.14, rounded up to 12. The tool uses that inclusive form, which is why it never produces a table that fails to hold the maximum. Rounding is always up to the next multiple of the recording precision, so decimal data gets decimal widths rather than integers forced on it. Our rounding calculator handles the general rounding rules if you want to check a step.

Advertisement

Limits Versus Boundaries — the Distinction That Matters

A class written as 12–23 for whole-number data does not really stop at 23. Any value that rounds to 23 belongs in it, so the class truly runs from 11.5 up to 23.5. Those two numbers are the class boundaries, and the gap of exactly one unit between the stated limits of consecutive classes exists only because the data is discrete.

The distinction has three practical consequences. First, a histogram is drawn on the boundaries, not the limits, because bars must touch — a gap between bars would falsely suggest that no values fall there. Second, the class width measured on the boundaries is 23.5 − 11.5 = 12, which equals the difference between consecutive lower limits and confirms that the width is 12 rather than the 11 you get by subtracting limits within one class. That last point catches out a great many students. Third, the boundaries are what you use for cumulative frequency curves, since the cumulative count applies at the true upper edge.

The NIST/SEMATECH e-Handbook of Statistical Methods discusses the equal-sized bins that this structure produces in section 1.3.3.14 on the histogram, including the point that the class definitions may be set by the user or by a systematic rule. Wolfram MathWorld's page on histograms gives the same grouping in terms of the class interval.

Choosing the Number of Classes

Nothing in statistics fixes the number of classes. Too few and the shape of the distribution disappears into a handful of tall bars; too many and the table becomes a list of ones and zeros with a jagged, meaningless profile. Most textbooks suggest between five and twenty, weighted towards the lower end for small samples.

Sturges' rule is the usual formula: take the base-two logarithm of the sample size, add one, and round up. For 30 observations that gives 6 classes; for 100 it gives 8; for 1,000 it gives 11. It grows very slowly, which is both its strength and its known weakness — it tends to produce too few classes for large samples and for strongly skewed data. The Rice rule, twice the cube root of the sample size, grows faster and is often preferred beyond a few hundred observations.

The practical advice is different from either. Compute the width for several class counts, which is exactly what the bar panel does, and pick the count whose width is a round number. A width of 10 or 25 or 100 produces limits a reader can hold in their head; a width of 8.5714 does not, however defensible the rule that produced it. Then check the table still looks sensible. Our mean, median and mode calculator and standard deviation calculator work from the raw values and are unaffected by whatever grouping you choose.

Where the Grouping Costs You Accuracy

Grouping throws information away, and it is worth knowing exactly how much. Once data is in classes, the mean is estimated by treating every observation as sitting at its class midpoint, which is the reason the midpoint column exists. That estimate is close but not exact, and it is systematically wrong whenever values within a class cluster towards one end — which is common in the first and last classes of a skewed distribution.

The same applies to the median and the quartiles, which are estimated by interpolating within the class that contains them. Our quartile calculator and interquartile range calculator compute these from raw values and will not agree exactly with the grouped estimates. That is expected, not an error in either, and if you have the raw data the ungrouped figures are the ones to report.

Two structural choices also matter. Open-ended classes such as "80 and over" have no upper limit, no midpoint and no width, so they cannot be plotted on a histogram or used in a grouped mean without inventing a limit. And unequal class widths, sometimes necessary for long-tailed data, require the histogram to plot frequency density rather than frequency — height equals frequency divided by width — or the picture will badly mislead. Our relative frequency calculator converts counts to proportions once the classes are settled.

Presenting data that has to be read correctly at a glance?

Arb Digital builds reporting that chooses its groupings deliberately rather than accepting whatever a default produced.

Browse All Free Tools Talk To Our Team

Common Mistakes to Avoid

  • Rounding the width down — always round up, and round up even when the division is exact, or the last class will not reach your maximum.
  • Measuring the width within one class — 23 minus 12 is 11, not the width. The width is the gap between consecutive lower limits, which is 12.
  • Confusing limits with boundaries — the limits are what you write in the table, the boundaries are the true edges half a unit outside them, and histograms are drawn on the boundaries.
  • Letting classes overlap — writing 10–20 and 20–30 leaves the value 20 belonging to both. Use 10–19 and 20–29 for whole-number data.
  • Treating Sturges' rule as compulsory — it is a starting suggestion that undercounts for large or skewed samples, not a requirement.

Related Free Tools From Arb Digital

Build the counted table from raw values with the frequency distribution calculator, draw the chart with the histogram calculator, convert counts to proportions with the relative frequency calculator, find the centre with the mean, median and mode calculator, or split the data into quarters with the quartile calculator. The full free online tools hub lists every statistics tool we publish.

Frequently Asked Questions

What is the formula for class width?

The range divided by the number of classes, then rounded up. The range is the largest value minus the smallest, and the rounding is always upwards so that the last class still contains the maximum.

Why round up when the division comes out exactly?

Because starting at the minimum and using the exact quotient leaves the largest value one unit outside the final class. Rounding up to the next unit guarantees the classes cover the whole range.

What is the difference between class limits and class boundaries?

Limits are the values written in the table, such as 12 to 23. Boundaries are the true dividing lines half a recording unit outside them, such as 11.5 to 23.5, and they are what a histogram is drawn on.

How do I find the class midpoint?

Add the lower and upper class limits and divide by two. The midpoint stands in for every value in the class when you estimate a mean from grouped data.

How many classes should I use?

Usually between five and twenty. Sturges' rule gives a starting figure from the sample size, but the better practical test is which class count produces a round, readable width.

Does the width have to be the same for every class?

Not always, but equal widths are strongly preferred. If you use unequal widths the histogram must plot frequency density, meaning frequency divided by width, or the taller bars will mislead.

Can the first class start above the minimum value?

No. Every observation must fall in exactly one class, so the first lower limit has to be at or below the smallest value. The tool refuses a starting point above it and says why.

How is this different from a frequency distribution calculator?

That tool takes your raw data and counts how many observations fall in each class. This one takes only a range and a class count and returns the class structure itself, including the boundaries and midpoints.

This page explains a standard method for grouping data for educational purposes. Grouped estimates of the mean and quartiles are approximations, and where raw data is available the ungrouped figures are the ones to report.

Advertisement
Advertisement

Take it further