# Are there any good general techniques for binning/histogramming arbitrary data?

Let's say we want to histogram a finite set of measurements of some quantity. It is straight forward to calculate the usual statistical quantities for our sample such as the mean and the variance. Let's assume we can clean up our data by identifying outliers and moving them into underflow and overflow bins and thus, define more or less optimal min and max values for the plotting range. But how would one decide on the number and the size of bins? I would like to know if there are methods to find the optimal binning for the cases with fixed and variable bin sizes.

2. Take the square root of the number of data points and round up to determine the initial number of bins required: $$InitialNumberOfBins = \sqrt{NumberOfDataPoints}$$.
3. Divide the specification tolerance $$Max-Min\ value$$ by initial number of bins: $$FinalNumberOfBins = (Max-Min\ value) / InitialNumberOfBins$$.