histogram(x, bins=10, range=None, weights=None, density=False, flow=False)¶
Histogram data in one dimension.
x (array_like) – data to histogram.
bins (int or array_like) – if int: the number of bins; if array_like: the bin edges.
weights (array_like, optional) – a set of weights associated with the elements of
x. This can also be a two dimensional set of multiple weights varitions with shape (len(x), n_weight_variations).
density (bool) – normalize counts such that the integral over the range is equal to 1. If
weightsis two dimensional this argument is ignored.
flow (bool) – if
True, include under/overflow in the first/last bins.
A simple fixed width histogram:
>>> h, __ = histogram(x, bins=20, range=(0, 100))
And with variable width histograms and weights:
>>> h, err = histogram(x, bins=[-3, -2, -1.5, 1.5, 3.5], weights=w)