pygram11.var1d¶
-
pygram11.
var1d
(x, bins, weights=None, density=False, flow=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 beNone
.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 the array of bin edges is not monotonically increasing.
ValueError – If
x
andweights
have incompatible shapes.TypeError – If
x
orweights
are unsupported types
- Returns
numpy.ndarray
– The bin counts.numpy.ndarray
, optional – The standard error of each bin count, \(\sqrt{\sum_i w_i^2}\). The return isNone
if weights are not used.
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)