# Rules of Thumb to choose an initial number of class intervals and refine that choice (potentially automatically)

I was wondering if there are established rules of thumb (or algorithms) that, given a set of observations can help:

1. choose an initial number of class intervals.
2. refine that choice to a better number.

I could find talk of using square-root(N), where N is the number of observations as an initial guess of the number of class intervals.

-
I remember reading some rules of thumb for this, but I can't remember which book had them. I think it might have been one of William Cleveland's books. –  Peter Flom Sep 24 '12 at 10:22
check out van Belle's Statistical Rules of Thumb. If he has a rule for this in there he will give a nice justification for it. –  Michael Chernick Sep 24 '12 at 11:44
What is the purpose of classification here? No rule of thumb can possibly cover even the commonest cases. For instance, a good rule of thumb for classifying observations as explanatory variates in regression modeling is not to do it. If the focus is on histograms, note that there are many, many procedures--and selecting one depends, once again, on how the histogram will be used –  whuber Sep 24 '12 at 14:17
@whuber where did you get the idea that the OP is talking about a classification problem?? It sound like he is just looking for rules of thumb for binning data for a histogram. I think it is common terminology to call the bin intervals class intervals. I think therre are reasonable rules of thumb that talk about taking the range of the data and dividing it into k equally spaced intervals where k is chosen as a function of the total sample size n. therre may be some exceptions on this when some of the cells are very sparse or empty and then a smaller choice for k would be picked. –  Michael Chernick Sep 24 '12 at 20:55
Of course just as with kernel density estimation there is always a degree of subjectivity regarding smoothness and roughness of the hitogram or the density and prior knowledge could come into play. Nevertheless rules of thumb are popular and sometimes rules can be set up that work in a large majority of cases. No rule holds without some exceptions. But some people like them because it simplifies decison making and doesn't require as much thought. But rules of thumb can be dangerous for that reason. –  Michael Chernick Sep 24 '12 at 21:01

The help of the R command hist http://stat.ethz.ch/R-manual/R-patched/library/grDevices/html/nclass.html has some references to algorithms for computing the number of the bins:

Sturges, H. A. (1926) The choice of a class interval. Journal of the American Statistical Association 21, 65–66.

Scott, D. W. (1979) On optimal and data-based histograms. Biometrika 66, 605–610.

Freedman, D. and Diaconis, P. (1981) On the histogram as a density estimator: L_2 theory. Zeitschrift für Wahrscheinlichkeitstheorie und verwandte Gebiete 57, 453–476.

-
The MASS book discusses this as well. –  cbeleites Apr 10 at 17:17
@cbeleites do you mean stats.ox.ac.uk/pub/MASS4 ? –  uvts_cvs Apr 10 at 17:29
yes exactly, thanks for the link. –  cbeleites Apr 10 at 20:56