Scott's rule

(Redirected from Scott's Rule)

Scott's rule is a method to select the number of bins in a histogram.[1] Scott's rule is widely employed in data analysis software including R,[2] Python [3] and Microsoft Excel where it is the default bin selection method.[4]

For a set of observations let be the histogram approximation of some function . The integrated mean squared error (IMSE) is

Where denotes the expectation across many independent draws of data points. By Taylor expanding to first order in , the bin width, Scott showed that the optimal width is

This formula is also the basis for the Freedman–Diaconis rule.

By taking a normal reference i.e. assuming that is a normal distribution, the equation for becomes

where is the standard deviation of the normal distribution and is estimated from the data. With this value of bin width Scott demonstrates that[5]

showing how quickly the histogram approximation approaches the true distribution as the number of samples increases.

Terrell–Scott rule edit

Another approach developed by Terrell and Scott[6] is based on the observation that, among all densities   defined on a compact interval, say  , with derivatives which are absolutely continuous, the density which minimises   is

 

Using this with   in the expression for   gives an upper bound on the value of bin width which is

 

So, for functions satisfying the continuity conditions, at least

 

bins should be used.[7]

 
10000 samples from a normal distribution binned using different rules. The Scott rule uses 48 bins, the Terrell-Scott rule uses 28 and Sturges's rule 15.

This rule is also called the oversmoothed rule[7] or the Rice rule,[8] so called because both authors worked at Rice University. The Rice rule is often reported with the factor of 2 outside the cube root,  , and may be considered a different rule. The key difference from Scott's rule is that this rule does not assume the data is normally distributed and the bin width only depends on the number of samples, not on any properties of the data.

In general   is not an integer so   is used where   denotes the ceiling function.

References edit

  1. ^ Scott, David W. (1979). "On optimal and data-based histograms". Biometrika. 66 (3): 605–610. doi:10.1093/biomet/66.3.605.
  2. ^ https://www.rdocumentation.org/packages/graphics/versions/3.6.2/topics/hist
  3. ^ https://numpy.org/doc/stable/reference/generated/numpy.histogram_bin_edges.html#numpy.histogram_bin_edges
  4. ^ "Excel:Create a histogram".
  5. ^ Scott DW. Scott's rule. Wiley Interdisciplinary Reviews: Computational Statistics. 2010 Jul; 2(4):497–502.
  6. ^ Terrell GR, Scott DW. Oversmoothed nonparametric density estimates. Journal of the American Statistical Association. 1985 Mar 1;80(389):209-14.
  7. ^ a b Scott, D.W. (2009). "Sturges' rule". WIREs Computational Statistics. 1 (3): 303–306. doi:10.1002/wics.35. S2CID 197483064.
  8. ^ Online Statistics Education: A Multimedia Course of Study (http://onlinestatbook.com/). Project Leader: David M. Lane, Rice University (chapter 2 "Graphing Distributions", section "Histograms")