# pygram11.var1d¶

pygram11.var1d(x, bins, weights=None, density=False, flow=False, cons_var=False)[source]

Histogram data with variable bin widths.

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

• bins (numpy.ndarray) – Bin edges

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

• cons_var (bool) – If True, conserve the variance rather than return the standard error (square root of the variance).

Raises
• ValueError – If the array of bin edges is not monotonically increasing.

• ValueError – If x and weights have incompatible shapes.

• TypeError – If x or weights are unsupported types

Returns

Examples

A simple histogram with variable width bins:

>>> rng = np.random.default_rng(123)
>>> x = rng.standard_normal(1000)
>>> edges = np.array([-3.0, -2.5, -1.5, -0.25, 0.25, 2.0, 3.0])
>>> h, __ = var1d(x, edges)