API Reference¶
Summary¶
|
Calculate the histogram for the data |
|
Histogram the same data but with multiple weight variations. |
Functions¶
-
humba.
histogram
(x: numpy.ndarray, bins: int = 10, range: Tuple[float, float] = (0, 10), weights: Optional[numpy.ndarray] = None, flow: bool = False) → Tuple[numpy.ndarray, Optional[numpy.ndarray], numpy.ndarray][source]¶ Calculate the histogram for the data
x
.- Parameters
x (
numpy.ndarray
) – data to histogrambins (int) – number of bins
weights (
numpy.ndarray
, optional) – array of weights forx
flow (bool) – include over and underflow content in first and last bins
- Returns
count (
numpy.ndarray
) – The values of the histogramerror (
numpy.ndarray
, optional) – The poission uncertainty on the bin heightsedges (
numpy.ndarray
) – The bin edges
Notes
If the dtype of the
weights
is not the same asx
, then it is converted to the dtype ofx
.Examples
>>> import numpy as np >>> from humba import histogram >>> x = np.random.randn(100000) >>> w = np.random.uniform(0.4, 0.5, x.shape[0]) >>> hist1, _, edges = humba.histogram(x, bins=50, range=(-5, 5)) >>> hist2, _, edges = humba.histogram(x, bins=50, range=(-5, 5), flow=True) >>> hist3, error, edges = histogram(x, bins=50, range=(-5, 5), weights=w) >>> hist4, error, edges = histogram(x, bins=50, range=(-3, 3), weights=w, flow=True)
-
humba.
mwv_histogram
(x: numpy.ndarray, weights: numpy.ndarray, bins: int = 10, range: Tuple[float, float] = (0, 10), flow: bool = False) → Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray][source]¶ Histogram the same data but with multiple weight variations.
- Parameters
x (
numpy.ndarray
) – data to histogramweights (
numpy.ndarray
, optional) – multidimensional array of weights forx
the first element of theshape
attribute must be equal to the length ofx
.bins (int) – number of bins
flow (bool) – include over and underflow content in first and last bins
- Returns
count (
numpy.ndarray
) – The values of the histograms calculated from the weights Shape will be (bins,weights.shape[0]
)error (
numpy.ndarray
) – The poission uncertainty on the bin heights (shape will be the same ascount
.edges (
numpy.ndarray
) – The bin edges
Notes
If
x
is not the same dtype asweights
, then it is converted to the dtype ofweights
(for multi weight histograms we expect the weights array to be larger than the data array so we prefer to cast the smaller chunk of data).