>>> h = Histogram()
"""
+ def calculate_bin_edges(self, data, bin_width):
+ """
+ >>> h = Histogram()
+ >>> h.calculate_bin_edges(numpy.array([-7.5, 18.2, 4]), 10)
+ array([-10., 0., 10., 20.])
+ >>> h.calculate_bin_edges(numpy.array([-7.5, 18.2, 4, 20]), 10)
+ array([-10., 0., 10., 20.])
+ >>> h.calculate_bin_edges(numpy.array([0, 18.2, 4, 20]), 10)
+ array([ 0., 10., 20.])
+ >>> h.calculate_bin_edges(numpy.array([18.2, 4, 20]), 10)
+ array([ 0., 10., 20.])
+ >>> h.calculate_bin_edges(numpy.array([18.2, 20]), 10)
+ array([ 10., 20.])
+ """
+ m = data.min()
+ M = data.max()
+ bin_start = m - m % bin_width
+ return numpy.arange(bin_start, M+bin_width, bin_width, dtype=data.dtype)
+
def from_data(self, data, bin_edges):
"""Initialize from `data`.