pygram11.var1dmw¶

pygram11.
var1dmw
(x, weights, bins, flow=False, cons_var=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 of x, second dimension is the number of weights.
bins (numpy.ndarray) – Bin edges.
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.
ValueError – If weights is not a two dimensional array.
TypeError – If x or weights are unsupported types
 Returns
numpy.ndarray
– The bin counts.numpy.ndarray
– The standard error of each bin count, \(\sqrt{\sum_i w_i^2}\). If cons_var isTrue
, the variances are returned.
Examples
Using three different weight variations:
>>> rng = np.random.default_rng(123) >>> x = rng.standard_normal(10000) >>> weights = np.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)