Skip to content
Statistics

Class Width Calculator

Enter the minimum value, maximum value, and number of classes to find the class width (class interval) for a frequency distribution or histogram. The calculator gives you the exact class width, a rounded "nice" width for cleaner boundaries, the suggestion from Sturges' rule, and a full table of class limits and midpoints so you can build your histogram immediately.

Your details

The smallest value in your dataset.
The largest value in your dataset.
How many bars (intervals) you want in the histogram. Typically 5-20. Use Sturges' rule as a guide.
The number of data points. Used only to compute Sturges' rule suggestion. Leave blank if unknown.
Class width
5

Exact class interval: range divided by number of classes

Range45
Rounded class width5
Sturges' rule: suggested classes6
Sturges' rule: suggested class width7.5
Exact class width5
Rounded class width5
Sturges' suggested width7.5

Class width is 5.0000 (rounded: 5.0000)

  • Your data spans a range of 45.0000, divided into 9 classes gives each bar a width of 5.0000.
  • Your chosen number of classes (9) aligns well with Sturges' suggestion of 6 for a sample of 30.
  • A class width that is too wide hides the shape of the distribution; one that is too narrow creates jagged, hard-to-read bars. Aim for 5-20 classes for most datasets.

Next stepOnce you have the class width, build your class intervals starting from the minimum value and add the class width repeatedly to find each boundary.

Class Intervals Table

Class #Lower BoundUpper BoundMidpoint
145.0050.0047.50
250.0055.0052.50
355.0060.0057.50
460.0065.0062.50
565.0070.0067.50
670.0075.0072.50
775.0080.0077.50
880.0085.0082.50
985.0090.0087.50

Lower bound is included in the class; upper bound belongs to the next class (standard half-open interval [lo, hi)). Midpoint = (lower + upper) / 2.

What is class width?

Class width, also called class interval or bin width, is the size of each bar in a histogram or frequency distribution table. Every class covers a range of values from its lower boundary (inclusive) to its upper boundary (exclusive), and all classes in a standard histogram have the same width. When you group raw data into classes and count how many values fall in each one, you create a frequency distribution that reveals the shape of your dataset at a glance.

The class width formula

The formula is straightforward: Class Width = (Maximum - Minimum) / Number of Classes. The numerator is the range of your data and the denominator is how many bars you want. For example, if your lowest test score is 45 and your highest is 90 and you want 9 classes, the range is 45 and the class width is 45 / 9 = 5. You would then create intervals 45-50, 50-55, 55-60, and so on up to 85-90.

How many classes should you use? Sturges' rule

Choosing the right number of classes is as important as calculating the width itself. Too few classes and you lose detail; too many and the histogram becomes noisy and hard to read. Sturges' rule offers a quick starting point: k = 1 + 3.322 x log10(n), where n is the number of data points. Round the result up to the nearest whole number. For 30 data points, Sturges gives k = 1 + 3.322 x log10(30) = 1 + 4.91 = 5.91, so you would use 6 classes. For 100 data points it gives about 8 classes, and for 1000 about 11. Most textbooks recommend staying between 5 and 20 classes for everyday datasets.

Rounding class width and setting boundaries

The exact class width often comes out as an awkward decimal. In practice it is easier to round up to a convenient number such as 0.5, 1, 2, 5, or 10 depending on your data scale. Rounding up, rather than rounding to nearest, ensures that all data points still fit within the range. After setting the class width, build your boundaries by starting at the minimum value (or a round number just below it) and adding the class width repeatedly. For example, with min = 45 and class width = 5, your boundaries are 45, 50, 55, 60, 65, 70, 75, 80, 85, 90. The first class is [45, 50), the second is [50, 55), and so on, where the bracket means the lower value is included and the parenthesis means the upper value is not.

Suggested number of classes by sample size (Sturges' rule)

Sample size (n)Suggested classes (k)Guidance
53Very small sample - use 3-4 classes
104Small sample - 4-5 classes
205Use 5-6 classes
3065-7 classes typical
5076-8 classes
10087-10 classes
20098-11 classes
500109-12 classes
10001110-13 classes
50001312-15 classes

Sturges' rule: k = ceil(1 + 3.322 x log10(n)). These are starting suggestions, not strict rules.

Frequently asked questions

What is the difference between class width and class interval?

They are the same thing. Class width, class interval, bin width, and bucket size all refer to the numeric size of each group in a frequency distribution or histogram. The terms are used interchangeably in most statistics textbooks.

Does class width have to be the same for all classes?

In a standard histogram, yes. Using equal class widths makes the areas of the bars proportional to the frequencies, which is what you want for a fair visual comparison. Unequal widths are occasionally used for open-ended classes (like "65 and over" in age data), but they require adjusting bar heights by frequency density rather than raw count, which complicates interpretation.

What is Sturges' rule and when should I use it?

Sturges' rule (k = 1 + 3.322 x log10(n)) gives a suggested number of classes based on sample size. It works best for roughly normal, unimodal distributions with moderate sample sizes (around 30 to 200). For very large datasets or highly skewed data, other rules like Scott's rule or the Freedman-Diaconis rule often give better results. Use Sturges as a starting point, then adjust by looking at the histogram.

Should I round the class width up or to the nearest value?

Always round up when the goal is to ensure all data points are covered. If you round down and the resulting boundaries fall short of the maximum value, you will have data points that do not fit into any class. Rounding up to a convenient number like 5 or 10 also makes the histogram easier to read.

How do I find the class width from a histogram already drawn?

Read the lower boundary of the first class and the lower boundary of the second class from the horizontal axis, then subtract: class width = second lower boundary minus first lower boundary. All bars in a standard histogram share the same width, so any two adjacent boundaries will give the same answer.

What is a class midpoint and why does it matter?

The midpoint is the average of the lower and upper boundaries of a class: midpoint = (lower + upper) / 2. Midpoints represent the entire class in calculations like the grouped mean, grouped variance, and grouped standard deviation. When you compute these statistics from a frequency table, you multiply each midpoint by the frequency of its class.

Sources

Written by Dr. Hannah Brandt, PhD Statistician · Munich, Germany

Applied statistician translating rigorous probability theory into clear, accurate tools for researchers and practitioners.

Search 3,500+ calculators

Loading search…