pygram11.fix2d¶
-
pygram11.
fix2d
(x, y, bins=10, range=None, weights=None, flow=False)[source]¶ Histogram the
x
,y
data with fixed (uniform) binning.The two input arrays (
x
andy
) must be the same length (shape).- Parameters
x (numpy.ndarray) – First entries in data pairs to histogram.
y (numpy.ndarray) – Second entries in data pairs to histogram.
bins (int or (int, int)) – If int, both dimensions will have that many bins; if tuple, the number of bins for each dimension
range (Sequence[Tuple[float, float]], optional) – Axis limits in the form
[(xmin, xmax), (ymin, ymax)]
. IfNone
the input data min and max will be used.weights (array_like, optional) – The weights for data element. If weights are absent, the second return type will be
None
.flow (bool) – Include over/underflow.
- Raises
ValueError – If
x
andy
have incompatible shapes.ValueError – If the shape of
weights
is incompatible withx
andy
TypeError – If
x
,y
, 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}\).
Examples
A histogram of (
x
,y
) with 20 bins between 0 and 100 in thex
dimention and 10 bins between 0 and 50 in they
dimension:>>> h, __ = fix2d(x, y, bins=(20, 10), range=((0, 100), (0, 50)))
The same data, now histogrammed weighted (via
w
):>>> h, err = fix2d(x, y, bins=(20, 10), range=((0, 100), (0, 50)), weights=w)