Calculadora de Histograma (largura de classe)

Largura = (max − min) / nº_classes. Regra de Sturges: k = 1 + log₂(n).
Created by
Renato Passos, Eng. de Software
Reviewed by
Renato Passos, Eng. de Software

Last updated: Apr 18, 2026

Classes (Sturges)
9
Largura
10,0000

Formula

k = 1 + log₂(n);  largura = (max − min) / k

About this calculator

The Histogram Calculator determines the optimal class width for building a histogram from a dataset. A histogram is a bar chart that groups data into intervals (classes) and shows the frequency of each interval. To calculate the class width, the calculator uses Sturges' rule, which estimates the number of classes as k = 1 + log₂(n), where n is the number of observations. Then, the width is obtained by dividing the total range (maximum value minus minimum value) by the number of classes.

You can use this tool whenever you need to visualize the frequency distribution of a dataset. For example, when analyzing student grades, population ages, or system response times. Simply enter the minimum and maximum values of the data and the total number of observations. The calculator will provide the class width and suggested number of classes, making it easier to create a histogram with appropriate intervals.

Important considerations: Sturges' rule works best for approximately normal distributions and up to 200 observations. For very large or skewed datasets, other rules (such as Scott's or Freedman-Diaconis) may be more appropriate. Additionally, the calculated width is a theoretical value; in practice, you can adjust class boundaries to make the histogram more readable, as long as you keep the number of classes close to the suggested value.

Frequently asked questions

How is the class width calculated?

The width is calculated as (maximum value − minimum value) divided by the number of classes, which is estimated by Sturges' rule: k = 1 + log₂(n), where n is the number of observations.

What is the purpose of Sturges' rule?

It provides an estimate of the optimal number of classes for a histogram, balancing the loss of detail (too few classes) and excessive noise (too many classes).

Does the calculator work for any sample size?

Sturges' rule is most suitable for samples up to 200 observations. For larger samples, other rules may be preferable.

Can I use the calculated width directly?

Yes, but it is common to adjust class boundaries to more convenient values (e.g., whole numbers) as long as the number of classes remains close to the suggested value.

What if the data is highly skewed?

For highly skewed distributions, consider using Scott's or Freedman-Diaconis rule, which are more robust. This calculator uses only Sturges.

Other Distribuicoes e Graficos calculators