Scott's algorithm for calculating bin width can be written as:
w = 3.49s/(n 1/3)
where w is the bin width, s is the standard deviation of the data values and n is the number of elements in the data set. The number of bins is r/w, where r is the range of the data values.
This algorithm performs best on normally distributed data.