pygram11.histogram¶
-
pygram11.
histogram
(x, bins=10, range=None, weights=None, density=False, flow=False)[source]¶ Histogram data in one dimension.
- Parameters
x (array_like) – data to histogram.
bins (int or array_like) – if int: the number of bins; if array_like: the bin edges.
range (tuple(float, float), optional) – the definition of the edges of the bin range (start, stop).
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
weights
is two dimensional this argument is ignored.flow (bool) – if
True
, include under/overflow in the first/last bins.
- Returns
numpy.ndarray
– The bin counts.numpy.ndarray
– The standard error of each bin count, \(\sqrt{\sum_i w_i^2}\).
Examples
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)