What is Sturges’ Rule?

Sturges’ Rule is a commonly used formula for determining the appropriate number of classes for a histogram or frequency distribution. It states that the number of classes should be equal to 1 + 3.3 log(n), where n represents the total number of data points. This rule helps to create a well-balanced and easily interpretable histogram, allowing for a more accurate representation of the data. It is named after the statistician Herbert Sturges, who first proposed this method in 1926.

What is Sturges’ Rule? (Definition & Example)


A histogram is a chart that helps us visualize the distribution of values in a dataset.

It turns out that the number of bins used in a histogram can have a huge impact on how we interpret the data.

If we use too few bins, the true underlying pattern in the data can be hidden:

And if we use too many bins, we may just be visualizing the noise in a dataset:

Fortunately, we can use a method known as Sturges’ Rule to determine the optimal number of bins to use in a histogram.

Sturges’ Rule uses the following formula to determine the optimal number of bins to use in a histogram:

Optimal Bins = ⌈log2n + 1⌉

where:

  • n: The total number of in the dataset.
  • ⌈ ⌉: Symbols that mean “ceiling” – i.e. round the answer up to the nearest integer.

Example: Sturges’ Rule

Suppose we have the following dataset with n = 31 total observations:

We can use Sturges’ Rule to determine the optimal number of bins to use to visualize these values in a histogram:

Optimal Bins = ⌈log2(31) + 1⌉ = ⌈4.954 + 1⌉ = ⌈5.954⌉ = 6.

According to Sturges’ Rule, we should use 6 bins in the histogram we use to visualize this distribution of values.

Using Sturges' rule to determine the number of bins to use in a histogram

Notice how this seems to be enough bins to get a good idea of the underlying distribution of values without being too many that we’re just visualizing the noise in the data.

Common Values for Sturges’ Rule

The following table shows the optimal number of bins to use in a histogram based on the total number of observations in a dataset, according to Sturges’ Rule:

Sturges's rule for different sample sizes

Alternatives to Sturges’ Rule

Sturges’ Rule is the most common method for determining the optimal number of bins to use in a histogram, but there are several alternative methods including:

The Square-root Rule: Number of bins = ⌈√n

The Rice Rule: Number of bins = ⌈2 * 3n

The Freedman-Diaconis’ Rule: Number of bins = (2*IQR) / 3n where IQR is the interquartile range.

Bonus: Sturges’ Rule Calculator

Use to automatically apply Sturges’ Rule to determine the optimal number of bins to use for a histogram based on the size of a dataset.

x