# pygram11.fix1dmw¶

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

Histogram data with multiple weight variations and fixed width bins.

The weights array must have a total number of rows equal to the length of the input data. The number of columns in the weights array is equal to the number of weight variations. (The weights array must be an M x N matrix where M is the length of x and N is the number of weight variations).

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

• weights (numpy.ndarray) – The weight variations for the elements of x, first dimension is the length of x, second dimension is the number of weights variations.

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

• 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 x and weights have incompatible shapes (if x.shape[0] != weights.shape[0]).

• ValueError – If weights is not a two dimensional array.

• TypeError – If x or weights are unsupported types

Returns

Examples

Multiple histograms of x using 20 different weight variations:

>>> rng = np.random.default_rng(123)
>>> x = rng.standard_normal(10000)
>>> twenty_weights = np.abs(rng.standard_normal((x.shape[0], 20)))
>>> h, err = fix1dmw(x, twenty_weights, bins=50, range=(-3, 3))


h and err are now shape (50, 20). Each column represents the histogram of the data using its respective weight.