There are various guidelines when picking the number of bins, where k is the number of bins and n is the range. The number of bins, k, can be calculated from a suggested bin width h as follows:
h = $\u2308\frac{\mathrm{maximum}-\mathrm{minimum}}{h}\u2309$,
where the braces indicate the ceiling function.
Square-root choice: The simplest method of deciding on the number of bins is to take square root of the number of data points.
k = $\sqrt{\mathit{n}}$
Sturges' formula: Sturges' Formula is derived from a binomial distribution and assumes that the data is normally distributed. Sturges' formula has been known to perform poorly in some cases if n is less than 30 and if the data is not normally distributed.
k = $\u2308{\mathrm{log}}_{2}\mathit{n}plus;1\u2309$
Scott's normal reference rule: Scott's normal reference rule minimizes the integrated mean squared error of the density estimate and is well suited for random samples of normally distributed data.
h = $\frac{3.5\stackrel{Hat;}{\mathrm{sigma;}}}{{n}^{\frac{1}{3}}}$,
where $\stackrel{\^}{\mathrm{\sigma}}$ is the sample standard deviation.
Freedman-Diaconis' choice: The Freedman-Diaconis' choice is based on the interquartile range (IQR). It is less sensitive to outliers in data than Scott's normal reference rule because of using the interquartile range.
h = $\frac{2\mathrm{IQR}\left(\mathrm{Sample}\right)}{{n}^{\frac{1}{3}}}$