pygram11.var1dmw¶
-
pygram11.
var1dmw
(x, weights, bins, flow=False)[source]¶ Histogram data with multiple weight variations and variable 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) – Weight variations for the elements of
x
, first dimension is the shape ofx
, second dimension is the number of weights.bins (numpy.ndarray) – Bin edges.
flow (bool) – Include under/overflow in the first/last bins.
- Raises
ValueError – If the array of bin edges is not monotonically increasing.
ValueError – If
x
andweights
have incompatible shapes.ValueError – If
weights
is not a two dimensional array.TypeError – If
x
orweights
are unsupported types
- Returns
numpy.ndarray
– The bin counts.numpy.ndarray
– The standard error of each bin count, \(\sqrt{\sum_i w_i^2}\).
Examples
Using three different weight variations:
>>> rng = np.random.default_rng(123) >>> x = rng.standard_normal(10000) >>> weights = nb.abs(rng.standard_normal((x.shape[0], 3))) >>> edges = np.array([-3.0, -2.5, -1.5, -0.25, 0.25, 2.0, 3.0]) >>> h, err = var1dmw(x, weights, edges) >>> h.shape (6, 3) >>> err.shape (6, 3)