- pygram11.fix1d(x, bins=10, range=None, weights=None, density=False, flow=False, cons_var=False)#
Histogram data with fixed (uniform) bin widths.
x (numpy.ndarray) – Data to histogram.
bins (int) – The number of bins.
weights (numpy.ndarray, optional) – The weights for each element of x. If weights are absent, the second return type will be
density (bool) – Normalize histogram counts as value of PDF such that the integral over the range is unity.
flow (bool) – Include under/overflow in the first/last bins.
cons_var (bool) – If
True, conserve the variance rather than return the standard error (square root of the variance).
A histogram of x with 20 bins between 0 and 100:
>>> rng = np.random.default_rng(123) >>> x = rng.uniform(0, 100, size=(100,)) >>> h, __ = fix1d(x, bins=20, range=(0, 100))
When weights are absent the second return is
None. The same data, now histogrammed with weights and over/underflow included:
>>> rng = np.random.default_rng(123) >>> x = rng.uniform(0, 100, size=(100,)) >>> w = rng.uniform(0.1, 0.9, x.shape) >>> h, stderr = fix1d(x, bins=20, range=(0, 100), weights=w, flow=True)