Question: 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.

Thanks in advance.

Answer: 
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.
See also
[HOGG, David W. Data analysis recipes: Choosing the binning for a histogram. arXiv preprint arXiv:0807.4820, 2008.](http://arxiv.org/pdf/0807.4820v1.pdf)

The abstract:

> 
> Data points are placed in bins when a histogram is created, but there
>  is always a decision to be made about the number or width of the bins.
>  This decision is often made arbitrarily or subjectively, but it need
>  not be. A jackknife or leave-one-out cross-validation likelihood is
>  defined and employed as a scalar objective function for optimization
>  of the locations and widths of the bins. The objective is justified as
>  being related to the histogram’s usefulness for predicting future
>  data. The method works for data or histograms of any dimensionality.
> 
> 
>