Sturges's rule

(Redirected from Sturges' Rule)


Sturges's rule[1] is a method to choose the number of bins for a histogram. Given observations, Sturges's rule suggests using

bins in the histogram. This rule is widely employed in data analysis software including Python[2] and R, where it is the default bin selection method.[3]

Sturges's rule comes from the binomial distribution which is used as a discrete approximation to the normal distribution.[4] If the function to be approximated is binomially distributed then

where is the number of trials and is the probability of success and . Choosing gives

In this form we can consider as the normalisation factor and Sturges's rule is saying that the sample should result in a histogram with bin counts given by the binomial coefficients. Since the total sample size is fixed to we must have

using the well-known formula for sums of the binomial coefficients. Solving this by taking logs of both sides gives and finally using (due to counting the 0 outcomes) gives Sturges's rule. In general Sturges's rule does not give an integer answer so the result is rounded up.

Doane's formula

edit

Doane[5] proposed modifying Sturges's formula to add extra bins when the data is skewed. Using the method of moments estimator

 

along with its variance

 

Doane proposed adding   extra bins giving Doane's formula

 

For symmetric distributions   this is equivalent to Sturges's rule. For asymmetric distributions a number of additional bins will be used.

Criticisms

edit
 
Histogram of 10,000 samples from a Gamma(2,2) distribution. Number of bins suggested by Scott's rule is 61, Doane's rule 21, and Sturges's rule 15.

Sturges's rule is not based on any sort of optimisation procedure, like the Freedman–Diaconis rule or Scott's rule. It is simply posited based on the approximation of a normal curve by a binomial distribution. Hyndman has pointed out[6] that any multiple of the binomial coefficients would also converge to a normal distribution, so any number of bins could be obtained following the derivation above. Scott[4] shows that Sturges's rule in general produces oversmoothed histograms i.e. too few bins, and advises against its use in favour of other rules such as Freedman-Diaconis or Scott's rule.

References

edit
  1. ^ Sturges, H. A. (1926). "The choice of a class interval". Journal of the American Statistical Association. 21 (153): 65–66. doi:10.1080/01621459.1926.10502161. JSTOR 2965501.
  2. ^ "Numpy.histogram_bin_edges — NumPy v2.1 Manual".
  3. ^ "Hist function - RDocumentation".
  4. ^ a b Scott, David W. (2009). "Sturges' rule". WIREs Computational Statistics. 1 (3): 303–306. doi:10.1002/wics.35. S2CID 197483064.
  5. ^ Doane DP (1976) Aesthetic frequency classification. American Statistician, 30: 181–183
  6. ^ Hyndman RJ. The problem with Sturges' rule for constructing histograms. Monash University. 1995 Jul 5:1-2.