Class Width Calculator
Calculate class width, range, and class intervals for grouped frequency tables, histograms, and data distributions.
Find the width of each class interval
A class width calculator finds the interval size for grouped data. Calculate class width by subtracting the minimum value from the maximum value, dividing by the number of classes, and rounding up for practical intervals: Class Width = (Max − Min) ÷ Number of Classes.
Enter the minimum and maximum values directly, or paste raw data so the calculator can identify them. The result stays hidden until you click Calculate Class Width, so changed inputs never leave an old answer on screen.
Exact class width
Rounded practical width: 0
Minimum
--
Maximum
--
Range
--
Classes
--
Calculation breakdown
Formula, inputs, and recommended interval width.
Interpretation
How to use the result for grouped data.
Suggested class intervals
Intervals use the rounded practical width so the maximum value is covered.
| Class | Lower limit | Upper limit | Interval |
|---|
How to Use This Calculator
Start with the information you have. The calculator can work from known bounds or from a pasted list of data values.
1. Choose an input method
Use known minimum and maximum values, or paste raw values if you want the calculator to find the bounds.
2. Enter the number of classes
The number of classes is the number of bins, bars, or groups you want in the frequency distribution.
3. Calculate class width
Click Calculate Class Width to get the range, exact class width, rounded practical width, and interval table.
4. Use intervals carefully
Use non-overlapping classes, and make sure the last class includes the maximum value.
Class Width Formula
Class width is the size of each interval in a grouped frequency distribution.
Range
range = maximum - minimum
Exact class width
exact width = range / classes
Rounded practical width
Round up when the exact width is awkward, especially for histogram bins.
Total covered span
covered span = rounded width x number of classes
Worked Examples
These examples show how class width changes with the range and number of classes.
| Situation | Known values | Calculation | Class width |
|---|---|---|---|
| Test scores | minimum 45, maximum 90, 9 classes | (90 - 45) / 9 | 5 |
| Wait times | minimum 3, maximum 41, 8 classes | 38 / 8 | 4.75, often rounded to 5 |
| Sensor values | minimum 1.2, maximum 6.8, 7 classes | 5.6 / 7 | 0.8 |
Interesting Fact
The same dataset can suggest very different class counts
Different bin rules can give very different answers for the same sample size. Using NumPy's documented formulas, 1,000 observations gives about 11 bins with Sturges' rule, 20 bins with Rice's rule, and about 32 bins with the square-root rule. That means class width is not just arithmetic; it also depends on how much detail you want the histogram to show. NumPy's histogram_bin_edges documentation lists the bin-count estimators and formulas used for this comparison.
How Many Classes Should You Use?
The number of classes controls how detailed the grouped distribution will be. Use these rules as starting points, then adjust for readability, sample size, and the story the histogram needs to show.
| Method | Quick rule | Best for | Watch out for |
|---|---|---|---|
| Square-root rule | classes near sqrt(n) | Fast classroom checks and small datasets. | Can be too simple for large datasets. |
| Sturges' rule | classes near 1 + log2(n) | Moderate data that is roughly bell-shaped. | May understate detail in skewed or very large data. |
| Rice rule | classes near 2 x cbrt(n) | A quick, more detailed alternative to Sturges' rule. | Can create awkward class widths that need rounding. |
| Practical reporting | usually 5 to 12 classes | Dashboards, reports, and quick frequency tables. | Needs judgment when outliers stretch the range. |
When two class-count rules give different answers, calculate both widths and compare the interval tables. The better choice is usually the one that keeps labels simple while still showing clusters, gaps, skew, and outliers.
Source: NumPy documents several automated histogram bin estimators, including Sturges, Rice, square-root, Scott, and Freedman-Diaconis methods, in numpy.histogram_bin_edges.
Class Limits, Boundaries, and Data Type
A class width is only useful when the interval boundaries are unambiguous. Choose boundaries that match whether your data is continuous, discrete, rounded, or measured in decimals.
Continuous data
Use less-than upper limits
For measurements such as time, height, weight, or temperature, write intervals as 10 to less than 15, then 15 to less than 20. This prevents a boundary value from fitting two classes.
Whole-number data
Match labels to possible values
For counts or scores, class labels such as 40-49, 50-59, and 60-69 are often easier to read than decimal boundaries. The displayed labels should still represent non-overlapping groups.
Rounded values
Keep precision consistent
If the data is rounded to one decimal place, avoid interval labels with unnecessary precision. A width of 0.5 or 1.0 is usually easier to explain than 0.482.
Boundary rule to reuse: every value should belong to exactly one class. If a value could fit two intervals, rewrite the class labels before building the frequency table or histogram.
Source: R's histogram documentation explains right-closed and left-closed interval handling in hist.
From Class Width to a Frequency Table
After the calculator gives a class width, the next step is sorting each observation into exactly one interval. This workflow turns the result into a frequency table you can use for a histogram or summary report.
| Step | Action | Example with width 5 | Quality check |
|---|---|---|---|
| 1 | Start the first class at or just below the minimum. | 45 to less than 50 | The minimum value is included. |
| 2 | Add the class width repeatedly to create limits. | 50 to less than 55, then 55 to less than 60 | Each interval has the same width. |
| 3 | Tally every data value into one interval. | 55 belongs in 55 to less than 60 | No value is counted twice. |
| 4 | Sum the frequencies and compare with sample size. | 15 data points should produce 15 tallies | The frequency total matches the dataset size. |
If the frequency total does not match the number of data values, the problem is usually an overlapping interval, a missing final class, or a boundary value that was handled inconsistently.
Source: Statistics Canada explains how histograms divide a data range into classes or groups and count observations in 5.7 Histogram.
Planning Good Class Intervals
A useful frequency distribution balances detail and readability. The class width should be wide enough to summarize the data, but not so wide that important patterns disappear.
Keep intervals equal
Use the same class width for every interval unless you have a specific statistical reason to use unequal bins.
Avoid overlapping limits
Intervals such as 10-20 and 20-30 can double-count 20. A clearer format is 10 to less than 20, then 20 to less than 30.
Round up when needed
If the exact class width is 4.75, a width of 5 is usually easier to label and still covers the full data range.
Common Class Width Mistakes
Most class-width errors come from choosing bins before checking the range and data type.
Using too many classes
Too many classes can make a histogram noisy and hard to interpret, especially with a small sample size.
Using too few classes
Too few classes can hide clusters, gaps, skew, or outliers that would matter in the distribution.
Not covering the maximum
If you round the class width down, the final interval may stop before the largest value. Round up when coverage is uncertain.
Class width questions
Frequently Asked Questions
Quick answers about range, class intervals, grouped data, frequency tables, histograms, and statistics calculator inputs.
What is class width?
Class width is the size of each interval in a grouped frequency distribution. It is also called bin width when you are building a histogram. For example, if one class is 10 to less than 20 and the next is 20 to less than 30, the class width is 10.
How do I calculate class width?
Subtract the minimum value from the maximum value to find the range, then divide the range by the number of classes. The formula is class width = (maximum - minimum) / number of classes. This calculator can use either known bounds or a pasted dataset to find those inputs.
Should I round the class width?
Often, yes. The exact class width is the mathematical result, but a rounded-up width is easier to use for class limits and histogram labels. Rounding up also helps make sure the largest value is included below the final upper limit.
What happens if the class width is too large or too small?
A class width that is too large can oversimplify the data and hide patterns. A class width that is too small can make the frequency distribution crowded, noisy, and harder to read.
Is class width the same as class interval?
Not exactly. A class interval is the full bin, such as 20 to less than 25. Class width is the size of that interval, which is 5 in this example. The lower limit starts the class, the upper limit ends it, and the class boundary rule decides how values on the edge are counted.
Can I use this for a histogram?
Yes. A histogram uses class intervals as bins, and each bin needs a clear class width. After calculating the width, count how many data values fall in each interval to build the frequency table behind the histogram.
What if my data includes decimals?
Decimal data can use decimal class widths. If the exact width is 0.73, you might use 0.75 or 1 depending on how precise the histogram or grouped data table needs to be for your statistics report.
Can I use the same class width for a sample and a population?
Yes, the class width formula works for either a sample or a full population as long as the minimum, maximum, and number of classes describe the same group. For a small sample, use fewer intervals so random gaps do not make the distribution look more detailed than it really is.
Disclaimer
This calculator is for educational, statistical, and planning use. It calculates class width from the values you provide and does not decide whether a particular grouping is best for every analysis.
For formal reports, research, business decisions, or high-stakes statistical work, review the dataset, sampling method, outliers, binning rule, and presentation goal with a qualified analyst.
Last updated: June 18, 2026