JuliaLang/julia — pull request #2687 by simonbyrne (2013-03-26 16:27:25+00:00)
Title: RFC: nice-ify histogram ranges, use range algorithm

This cleans up the `hist` code by calculating the bin of a range directly, rather than searching over a vector. It also adds `nicerange` command for constructing ranges with steps of `10^n`, `2*10^n`, and `5*10^n`, and makes this the default (similar to R). As a result, specifying an integer `n` as the number of bins is now a guide, rather than a hard rule.

Also adds a `midpoints` method for calculating the midpoints of the bins.

The output has changed slightly: if the edge vector is of length `n`, there will be `n-1` bins (previously, the last bin was always empty). Also, the each element will end up in the largest bin for which it is *less than or equal* to the upper edge (which means it now plays nicely with integers).

All columns in an array now use the same edges.

I haven't resolved #2335 yet, as it is not clear what the usage should be (should all `hist` methods return the bins?). In the meantime, you can use two separate calls
```julia
bins = nicerange(v,n)
h = hist(v,bins)
```