pygram11.bin_centers#
- pygram11.bin_centers(bins, range=None)[source]#
Construct array of center values for each bin.
- Parameters
- Returns
Array of bin centers.
- Return type
- Raises
ValueError – If bins is an integer and range is undefined (
None
).
Examples
The centers given the number of bins and max/min:
>>> bin_centers(10, range=(-3, 3)) array([-2.7, -2.1, -1.5, -0.9, -0.3, 0.3, 0.9, 1.5, 2.1, 2.7])
Or given bin edges:
>>> bin_centers([0, 1, 2, 3, 4]) array([0.5, 1.5, 2.5, 3.5])