# What class width do I use?

Finds the class width for a frequency table or histogram from the smallest and largest data values and the number of classes, rounded up so that no value falls on a class boundary.

- Page: https://www.acalculator.org/statistics/class-width-calculator
- JSON spec: https://www.acalculator.org/statistics/class-width-calculator.json
- Version: 0ff475d88aa8

## Default answer

Example with the default inputs (Smallest data value 60, Largest data value 74, Number of classes 8, Decimal places in the data 1, Round the width up to a multiple of 1): With 8 classes from 60 to 74, use a class width of 2.

## Inputs

| Key | Label | Description |
| --- | --- | --- |
| min | Smallest data value | The smallest number in the data set. |
| max | Largest data value | The largest number in the data set. |
| k | Number of classes | How many classes (bars) the table or histogram should have. |
| dp | Decimal places in the data | The most decimal places any data value has: 0 for whole numbers, 1 for values such as 61.5. |
| step | Round the width up to a multiple of | The rounding step for the class width: 1 rounds up to a whole number, 0.1 to a tenth. |
| n | Number of data values (optional) | How many values the data set has, for a suggested number of classes (about √n). |

## Outputs

| Key | Label | Description |
| --- | --- | --- |
| width | Class width | The width before rounding, rounded up to the next multiple of the rounding step (kept if it is one). |
| raw | Width before rounding | (Ending value − starting point) ÷ number of classes. |
| simple | Range ÷ number of classes | (Largest − smallest) ÷ number of classes, the short formula. |
| range | Range | Largest data value − smallest data value. |
| start | Starting point | The lower boundary of the first class: the smallest value − half a data unit. |
| end | Ending value | The largest value + half a data unit. |
| top | Last class ends at | Starting point + number of classes × class width. |
| suggested | Suggested number of classes (√n) | The square root of the number of data values, rounded to the nearest whole number. |

## Method

Starting point = smallest − ½ × 10^−d; ending value = largest + ½ × 10^−d (d = decimal places in the data); width before rounding = (ending value − starting point) ÷ classes; class width = that width rounded up to a multiple of the step.

## Assumptions

- Classes have equal widths and start at the starting point, half a data unit below the smallest value, so no data value falls on a boundary.
- A width that is already a multiple of the rounding step is kept as it is.
- The suggested number of classes is √n rounded to the nearest whole number, a guideline some authors follow.

## Worked examples

1. min = 60, max = 74, k = 8, dp = 1, step = 1 gives start = 59.95, end = 74.05, raw = 1.7625, width = 2, simple = 1.75, range = 14, top = 75.95. Source: OpenStax, Introductory Statistics 2e, §2.2 Histograms, Frequency Polygons, and Time Series Graphs (Example 2.7: start 60 − 0.05 = 59.95, end 74 + 0.05 = 74.05, (74.05 − 59.95) ÷ 8 = 1.76, rounded up to 2; Example 2.8: 0.5 to 6.5 in 6 bars of width 1; about √n bars), https://openstax.org/books/introductory-statistics-2e/pages/2-2-histograms-frequency-polygons-and-time-series-graphs (retrieved 2026-10-18).
2. min = 1, max = 6, k = 6, dp = 0, step = 1 gives start = 0.5, end = 6.5, raw = 1, width = 1, top = 6.5. Source: OpenStax, Introductory Statistics 2e, §2.2 Histograms, Frequency Polygons, and Time Series Graphs (Example 2.7: start 60 − 0.05 = 59.95, end 74 + 0.05 = 74.05, (74.05 − 59.95) ÷ 8 = 1.76, rounded up to 2; Example 2.8: 0.5 to 6.5 in 6 bars of width 1; about √n bars), https://openstax.org/books/introductory-statistics-2e/pages/2-2-histograms-frequency-polygons-and-time-series-graphs (retrieved 2026-10-18).
3. min = 10, max = 50, k = 4, dp = 0, step = 1, n = 150 gives raw = 10.25, width = 11, simple = 10, start = 9.5, top = 53.5, suggested = 12. Source: OpenStax, Introductory Statistics 2e, §2.2 Histograms, Frequency Polygons, and Time Series Graphs (Example 2.7: start 60 − 0.05 = 59.95, end 74 + 0.05 = 74.05, (74.05 − 59.95) ÷ 8 = 1.76, rounded up to 2; Example 2.8: 0.5 to 6.5 in 6 bars of width 1; about √n bars), https://openstax.org/books/introductory-statistics-2e/pages/2-2-histograms-frequency-polygons-and-time-series-graphs (retrieved 2026-10-18) (150 values: √150 ≈ 12.25, so 12 bars).
4. min = 2.13, max = 9.87, k = 5, dp = 2, step = 0.1 gives start = 2.125, end = 9.875, raw = 1.55, width = 1.6, top = 10.125. Source: OpenStax, Introductory Statistics 2e, §2.2 Histograms, Frequency Polygons, and Time Series Graphs (Example 2.7: start 60 − 0.05 = 59.95, end 74 + 0.05 = 74.05, (74.05 − 59.95) ÷ 8 = 1.76, rounded up to 2; Example 2.8: 0.5 to 6.5 in 6 bars of width 1; about √n bars), https://openstax.org/books/introductory-statistics-2e/pages/2-2-histograms-frequency-polygons-and-time-series-graphs (retrieved 2026-10-18).

## FAQ

### How do I calculate class width?

Start half a data unit below the smallest value and end half a unit above the largest. Divide that span by the number of classes, then round up. For heights from 60 to 74 inches recorded to one decimal place, in 8 classes: (74.05 − 59.95) ÷ 8 = 1.7625, so use a width of 2.

### Why is the class width rounded up?

Rounding up makes the classes cover all the data with a little to spare. With the starting point half a unit below the smallest value and a width that is a whole number of data units, every class boundary falls between data values, so no value sits on a boundary.

### Why not just divide the range by the number of classes?

(Largest − smallest) ÷ classes is the short formula, and the page shows it too. If it divides exactly, the largest value lands on the top boundary of the last class. Adding half a unit at each end avoids that: whole numbers from 10 to 50 in 4 classes need a width of 11, not 10.

### How many classes should I use?

Many histograms have 5 to 15 classes. One guideline is the square root of the number of data values, rounded to the nearest whole number: 150 values suggest 12 classes. Type the number of values to see the suggestion.

### What starting point should I use?

Use the smallest value minus half a data unit: 59.95 for data with one decimal place and a smallest value of 60, or 0.5 for whole numbers starting at 1. The first class runs from the starting point to the starting point plus the class width.

### What if my data have decimals?

Set the number of decimal places in the data. Values such as 61.5 have one, so the half unit is 0.05. You can also round the width up to a tenth or another step instead of a whole number.

## Sources

- OpenStax, Introductory Statistics 2e, §2.2 Histograms, Frequency Polygons, and Time Series Graphs: the starting point is one decimal place beyond the data (60 − 0.05 = 59.95), the ending value 74 + 0.05 = 74.05, the width (ending value − starting point) ÷ number of bars = 1.76, rounded up to 2; Example 2.8 runs from 0.5 to 6.5; five to 15 bars; about √n bars (150 values, 12 bars). https://openstax.org/books/introductory-statistics-2e/pages/2-2-histograms-frequency-polygons-and-time-series-graphs (retrieved 2026-10-18)
