BY: Statistics Fundamentals Team
Reviewed By: Minsa A (Senior Statistics Editor)

Class Width Calculator & Frequency Distribution Guide

Enter your raw data or summary values (min, max, and number of classes) and get the class width, class limits, class boundaries, midpoints, and a complete frequency distribution table instantly — with a histogram preview and export options. Works client-side with no signup required.

Class Width Calculator

Formula w = ⌈Range / k⌉   |   Range = xmax − xmin
Formula w = ⌈(Max − Min) / k⌉

Run a calculation in the Raw Data or Min / Max / k tab first, then return here to see the full step-by-step solution.

No data yet — enter values in the Raw Data or Min / Max / k tab first.

What Is Class Width in Statistics?

Class width (also called class interval size or class size) is the difference between the lower limit of one class and the lower limit of the next consecutive class in a frequency distribution table. When you have a large dataset of raw numbers, grouping those values into equal-width bins makes patterns visible: you can see where data clusters, where it spreads thin, and whether the distribution skews left or right.

The class width is the same number throughout a standard frequency distribution. Every bin covers the same span of values, which keeps the histogram visually honest — bar height directly reflects how many data points fell in that range. If you group exam scores into classes like 50–59, 60–69, 70–79, the class width is 10 throughout the table.

Quick example: Scores range from 52 to 98. With 5 classes, the raw width is (98 − 52) / 5 = 9.2. Rounded up, the class width is 10. The five classes become 50–59, 60–69, 70–79, 80–89, and 90–99.

Choosing the right class width is a balance. Too narrow and you get dozens of nearly empty bins; too wide and genuine shape differences disappear inside a few giant buckets. The rules covered in the next section give you a defensible starting point, which you can then adjust based on what the data looks like.

The Class Width Formula

The class width formula divides the data range by the number of classes, then rounds the result up to the next whole number (or the same decimal precision as the data). The ceiling operator is not optional — rounding down or using standard rounding can leave the maximum value outside the last bin.

Step 1 — Find the Range

Range = xmax − xmin

Step 2 — Divide and Round Up

Class Width (w) = ⌈Range / k⌉ where k = number of classes ⌈·⌉ = ceiling (always round UP)

If Range / k works out to an exact integer, the convention in most textbooks is to increment by one unit of precision anyway — so the final class still covers the maximum value with a small margin, rather than sitting exactly at the upper boundary of the last bin.

Rules for Determining the Number of Classes (k)

No single rule works best for every dataset. The four options below — Sturges' Rule, the Square Root Rule, the Rice Rule, and a custom count — each make different assumptions about your data and sample size. Use the table to pick the right one, then let the class width calculator above handle the arithmetic.

Rule Formula Best for n Use case
Custom / Manual User specified Any Domain-standard bins (e.g., age groups by decade, income brackets)
Square Root k = ⌈√n⌉ n < 50 Quick mental calculation; exploratory first look at small samples
Sturges' Rule k = ⌈1 + 3.322 × log10(n)⌉ 20 ≤ n ≤ 200 Standard textbook rule; works well for roughly symmetric data
Rice Rule k = ⌈2 × n1/3 n > 200 Larger samples where Sturges under-bins and loses distributional shape

Sturges' Rule dates to a 1926 paper and remains the most common choice in introductory statistics courses. The Square Root Rule is fast enough to compute by hand. The Rice Rule was developed specifically because Sturges tends to suggest too few classes when n grows large, smoothing over variation that deserves its own bin. None of the three is universally correct — treat them as starting points and look at the histogram to decide whether to merge or split classes.

Anatomy of a Frequency Distribution Bin

Each row in a frequency distribution table has six components: the lower class limit, the upper class limit, the lower class boundary, the upper class boundary, the class midpoint, and the frequency count. Getting these right matters most when you build histograms or compute weighted means from grouped data.

Component Definition Example (10–19) How to find it
Lower Class Limit (LCL) Smallest value that belongs to this class 10 First bin starts at xmin (or a convenient lower bound)
Upper Class Limit (UCL) Largest value that belongs to this class 19 LCL + Class Width − 1 (for integer data)
Lower Class Boundary (LCB) Continuous lower endpoint (closes the gap with the previous class) 9.5 LCL − 0.5
Upper Class Boundary (UCB) Continuous upper endpoint 19.5 UCL + 0.5
Class Midpoint (xm) Center value of the bin, used in grouped mean calculations 14.5 (LCL + UCL) / 2
Class Width Distance between consecutive lower limits 10 LCL2 − LCL1 = 20 − 10 = 10

A note on class limits vs. boundaries: class limits are the values you write in the table (10–19, 20–29). They leave apparent gaps between classes for integer data. Class boundaries (9.5–19.5, 19.5–29.5) are the continuous numbers used when drawing histogram bars so they touch each other with no visible gap. Both describe the same bin — they are just two representations of the same interval.

How to Calculate Class Width — Worked Example

To calculate class width: find the range, apply Sturges' Rule to estimate the number of classes, divide range by k, and round up. Then build the class intervals from the minimum value. Here is a complete walkthrough with a dataset of 20 exam scores.

Dataset (n = 20 exam scores):

52, 55, 61, 64, 68, 70, 72, 73, 75, 78, 80, 81, 84, 85, 88, 90, 91, 93, 95, 98
1
Identify Min, Max, and Range

xmin = 52    xmax = 98    Range = 98 − 52 = 46

2
Determine k using Sturges' Rule

k = ⌈1 + 3.322 × log10(20)⌉ = ⌈1 + 3.322 × 1.301⌉ = ⌈5.32⌉ = 5 classes

3
Calculate and round up class width

Raw width = 46 / 5 = 9.2  →  Class Width = ⌈9.2⌉ = 10

4
Build the class intervals (starting at 50 for a clean lower bound)

50–59, 60–69, 70–79, 80–89, 90–99

5
Tally frequencies and complete the table

Count how many scores fall in each interval: 50–59 has 2, 60–69 has 3, 70–79 has 5, 80–89 has 5, 90–99 has 5.

Class Limits Class Boundaries Midpoint Frequency (f) Relative Freq.
50 – 5949.5 – 59.554.520.10 (10%)
60 – 6959.5 – 69.564.530.15 (15%)
70 – 7969.5 – 79.574.550.25 (25%)
80 – 8979.5 – 89.584.550.25 (25%)
90 – 9989.5 – 99.594.550.25 (25%)

Result: Range = 46, k = 5 (Sturges' Rule), Class Width = 10. You can paste the raw scores into the calculator above to verify and generate this table automatically.

Class Width in Python, R, and Excel

The formula is simple enough to implement in any language. The examples below use the same 20-score dataset from the worked example above.

Python (numpy + math)
import math data = [52, 55, 61, 64, 68, 70, 72, 73, 75, 78, 80, 81, 84, 85, 88, 90, 91, 93, 95, 98] n = len(data) min_val = min(data) max_val = max(data) rng = max_val - min_val # Sturges' Rule k = math.ceil(1 + 3.322 * math.log10(n)) # Class width — always round UP width = math.ceil(rng / k) print(f"Range: {rng}") # 46 print(f"Classes (k): {k}") # 5 print(f"Class Width: {width}") # 10
R Language
data <- c(52, 55, 61, 64, 68, 70, 72, 73, 75, 78, 80, 81, 84, 85, 88, 90, 91, 93, 95, 98) n <- length(data) rng <- max(data) - min(data) k <- ceiling(1 + 3.322 * log10(n)) width <- ceiling(rng / k) cat("Range:", rng, "| Classes:", k, "| Class Width:", width) # Range: 46 | Classes: 5 | Class Width: 10
Microsoft Excel / Google Sheets (data in A1:A20)
=MIN(A1:A20) ' Minimum =MAX(A1:A20) ' Maximum =MAX(A1:A20)-MIN(A1:A20) ' Range =ROUNDUP(1+3.322*LOG10(COUNT(A1:A20)),0) ' k — Sturges =ROUNDUP((MAX(A1:A20)-MIN(A1:A20))/ ROUNDUP(1+3.322*LOG10(COUNT(A1:A20)),0),0) ' Class Width

Where Class Width Gets Used

Frequency distributions and class widths show up in more places than statistics courses. The same grouping logic runs behind dashboards, reports, and data pipelines across several fields.

Demographics and census research. Age groups (0–9, 10–19, 20–29) are frequency bins with a class width of 10. Population pyramids are grouped frequency histograms plotted back-to-back for two series.

Finance and income analysis. Income distribution studies group salaries into brackets. The shape of that distribution — how many bins have high frequencies, where the tail thins out — drives policy decisions about tax brackets and benefit thresholds.

Operations and supply chain. Package weights, delivery times, and defect rates are binned to build control charts. A process running in control should show a roughly symmetric frequency distribution with most counts near the center bins.

Education and assessment. Grade distributions, standardized test scores, and reading level assessments all use grouped frequency tables to report results at scale without sharing every individual data point.

For more on how frequency distributions connect to broader statistical inference, see the Descriptive Statistics guide and the Types of Data page. For graphing the result, the Histogram Maker and Bar Chart Maker accept the bin counts directly.

Three Mistakes to Avoid

Rounding down instead of up. This is the most common arithmetic error. If Range / k = 9.2, the class width is 10, not 9. Using 9 leaves the value 98 outside the last class (which would end at 52 + 5×9 − 1 = 96).

Subtracting the lower limit from the upper limit of the same class. For the class 10–19, that calculation gives 19 − 10 = 9, not the class width of 10. Class width is always the lower limit of the next class minus the lower limit of the current class: 20 − 10 = 10.

Confusing class limits with class boundaries. When plotting a histogram, the bars should touch — that requires boundaries (9.5, 19.5, 29.5…), not limits (10, 19, 20, 29…). Using limits directly creates gaps between bars that make the distribution look discontinuous when it is not.

Frequently Asked Questions

How do you find class width from an existing frequency table?

Subtract the lower limit of any class from the lower limit of the next class. For example, if consecutive lower limits are 10 and 20, the class width is 10. Do not subtract lower from upper within the same row — that gives class width minus one for integer data.

Why do you always round up when calculating class width?

Rounding up guarantees that the maximum data value falls inside the last class interval. Rounding down, or using standard rounding that sometimes rounds down, can push the highest value outside the final bin, breaking the frequency table.

What is Sturges' Rule, and when should I use it?

Sturges' Rule estimates the number of classes as k = ⌈1 + 3.322 × log10(n)⌉. It was derived for normally distributed data and works well for sample sizes between roughly 20 and 200. For smaller samples the Square Root Rule is simpler; for larger samples the Rice Rule prevents too few classes.

What is the difference between class limits and class boundaries?

Class limits are the values printed in the frequency table (10–19, 20–29) and represent actual data values. Class boundaries (9.5–19.5, 19.5–29.5) are continuous endpoints used to draw histograms without gaps. Both describe the same interval — the choice of which to show depends on the context.

Can class widths be unequal?

For most textbook problems and standard analyses, equal class widths are expected. Unequal widths appear in income data (where the top bracket is open-ended, e.g., “$100,000+”) and in age group tables that intentionally group certain ranges differently. When widths are unequal, a standard frequency histogram is misleading — you need a frequency density histogram (frequency divided by class width) so that area, not bar height, represents count.

Related Calculators and Guides