pygram11.fix1d¶

pygram11.fix1d(x, bins=10, range=None, weights=None, density=False, flow=False)[source]

Histogram data with fixed (uniform) bin widths.

Parameters
• x (numpy.ndarray) – Data to histogram.

• bins (int) – The number of bins.

• range ((float, float), optional) – The minimum and maximum of the histogram axis. If None, min and max of x will be used.

• weights (numpy.ndarray, optional) – The weights for each element of x. If weights are absent, the second return type will be None.

• 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.

Raises
• ValueError – If x and weights have incompatible shapes.

• TypeError – If x or weights are unsupported types

Returns

Examples

A histogram of x with 20 bins between 0 and 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)
>>> w = rng.uniform(0.1, 0.9, x.shape[0]))
>>> h, stderr = fix1d(x, bins=20, range=(0, 100), weights=w, flow=True)