Scott's rule

From testwiki
Jump to navigation Jump to search

Template:Short description

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 n observations xi let f^(x) be the histogram approximation of some function f(x). The integrated mean squared error (IMSE) is

IMSE=E[dx(f^(x)f(x))2]

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

h*=(6/f(x)2dx)1/3n1/3

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

By taking a normal reference i.e. assuming that f(x) is a normal distribution, the equation for h* becomes

h*=(24π)1/3σn1/33.5σn1/3

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]

IMSEn2/3

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

Terrell–Scott rule

Another approach developed by Terrell and Scott[6] is based on the observation that, among all densities g(x) defined on a compact interval, say |x|<1/2, with derivatives which are absolutely continuous, the density which minimises dx(g(k)(x))2 is

fk(x)={(2k+1)!22k(k!)2(14x2)k,|x|1/20|x|>1/2

Using this with k=1 in the expression for h* gives an upper bound on the value of bin width which is

hTS*=(4n)1/3.

So, for functions satisfying the continuity conditions, at least

kTS=bah*=(2n)1/3

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, 2(n)1/3, 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 (2n)1/3 is not an integer so (2n)1/3 is used where denotes the ceiling function.

References

Template:Reflist

  1. Template:Cite journal
  2. Template:Cite web
  3. Template:Cite web
  4. Template:Cite web
  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. 7.0 7.1 Template:Cite journal
  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")