Class Width Calculator

Quick answer

The class width calculator divides the range of your data (maximum minus minimum) by the number of classes to give the width of each class for a frequency table or histogram, rounds it up to a convenient value and suggests a class count from Sturges, Rice and square-root rules.

Optional – used only for the suggested numbers of classes.

Class width (exact)
5
Class width (rounded up)
5
Range (max − min)
45
First class
45
First class upper limit (= next lower limit)
50
Upper limit of the last class
90
Sturges' rule – suggested classes
5
Rice rule – suggested classes
5
Square-root rule – suggested classes
4
Class width with Sturges' classes
9

Before you can draw a histogram or build a grouped frequency table you have to cut the range of the data into classes (bins) of equal width. The class width is simply the range divided by the number of classes you want: data from 45 to 90 split into 9 classes gives classes 5 units wide.

In practice the exact quotient is usually rounded up to a tidy number (a whole number, a multiple of 5 or one decimal place) so the class limits are easy to read and the last class still reaches the maximum. Rounding up rather than down matters: a width that is too small leaves the largest values outside the final class.

How many classes? Too few hide the shape of the data, too many make every bar tiny and jagged. Most textbooks recommend 5 to 20. If you are unsure, the calculator lists three popular rules based on the sample size: Sturges’ rule (good for roughly bell-shaped data up to a few hundred values), Rice’s rule (a few more classes) and the square-root rule used by many spreadsheet tools.

How to use the Class Width Calculator

  1. Maximum value
  2. Minimum value
  3. Number of classes
  4. Round the width up to
  5. Number of data values (for the class-count rules): Optional, used only for the suggested numbers of classes.

Results update as you type, and everything is calculated in your browser.

How it works

Subtract the minimum from the maximum to get the range, divide by the number of classes and, if you choose, round the result up to the selected step. The first class starts at the minimum; each following lower limit adds one class width.

Worked example

Fifteen test marks range from 45 to 90. With 9 classes the class width is (90 − 45) ÷ 9 = 5, giving classes 45–50, 50–55, … 85–90. For 15 values Sturges’ rule suggests ⌈1 + log₂ 15⌉ = ⌈4.91⌉ = 5 classes, which would make each class (90 − 45) ÷ 5 = 9 wide; the square-root rule suggests ⌈3.87⌉ = 4 classes.

Suggested number of classes by sample size

Values (n) Sturges Rice Square root
20 6 6 5
50 7 8 8
100 8 10 10
200 9 12 15
500 10 16 23
1000 11 20 32

Inputs explained

Field What to enter
Maximum value A number
Minimum value A number
Number of classes A number
Round the width up to Choose one: Do not round, Whole number, 0.1, 0.01 …
Number of data values (for the class-count rules) A number. Optional, used only for the suggested numbers of classes.

What each result means

  • Class width (exact) = ([Maximum value] – [Minimum value])÷[Number of classes]
  • Range (max − min) = [Maximum value] – [Minimum value]
  • First class upper limit (= next lower limit) = [Minimum value] + [Class width (rounded up)]
  • Upper limit of the last class = [Minimum value] + [Number of classes]×[Class width (rounded up)]
  • Sturges’ rule: suggested classes = ceil(1 + log([Number of data values (for the class-count rules)], 2))
  • Rice rule: suggested classes = ceil(2×cbrt([Number of data values (for the class-count rules)]))
  • Square-root rule: suggested classes = ceil(sqrt([Number of data values (for the class-count rules)]))
  • Class width with Sturges’ classes = ([Maximum value] – [Minimum value])÷[Sturges’ rule: suggested classes]

Formula

Class width = (maximum − minimum) ÷ number of classes · Sturges: k = ⌈1 + log₂ n⌉ · Rice: k = ⌈2·∛n⌉ · Square root: k = ⌈√n⌉

Worked example

Inputs: Maximum value: 90; Minimum value: 45; Number of classes: 9; Round the width up to: Whole number; Number of data values (for the class-count rules): 15.
Results: Class width (exact) = 5; Class width (rounded up) = 5; Range (max − min) = 45; First class = 45; First class upper limit (= next lower limit) = 50; Upper limit of the last class = 90; Sturges' rule – suggested classes = 5; Rice rule – suggested classes = 5; Square-root rule – suggested classes = 4; Class width with Sturges' classes = 9.

Key terms

Class (bin)
One of the equal-width intervals the data are sorted into.
Class width
The difference between consecutive lower class limits.
Range
Maximum minus minimum value.
Sturges' rule
k = 1 + log₂ n, a common rule of thumb for the number of classes.

Frequently asked questions

How do you calculate class width?

Class width = (max − min) ÷ number of classes. For data from 45 to 90 in 9 classes: (90 − 45) ÷ 9 = 5.

Should I round class width up or down?

Always up. With data from 10 to 97 in 6 classes the exact width is 14.5; rounding up to 15 makes the classes cover 10 to 100, while rounding down to 14 would end at 94 and miss the top values.

What if the width comes out as a whole number?

Some textbooks add 1 so the maximum falls inside the last class rather than on its upper limit. If your classes include their upper limit in the final class, as this site's histogram does, no adjustment is needed.

How many classes should I use?

Usually 5 to 20. Sturges' rule gives ⌈1 + log₂ n⌉: 7 classes for 50 values and 8 for 100.

Is class width the same as class interval?

They are often used interchangeably. Strictly, the class interval is the range a class covers, and its width is its upper minus its lower limit.

How do I find the class width from a frequency table?

Subtract one class's lower limit from the next class's lower limit, e.g. 20 − 15 = 5.

Can classes have different widths?

Yes, but then the histogram must show frequency density (frequency ÷ width) on the vertical axis. This calculator assumes equal widths.

Sources

  1. OpenStax: Introductory Statistics 2e
  2. NIST/SEMATECH e-Handbook: Histogram

Cite this calculator

Speedy Calculator. (2026). Class Width Calculator. Speedy Calculator. https://speedycalculator.com/calculators/statistics/class-width/