tdub.hist¶
A module for histogramming
Class Summary¶
|
Systematic template histogram comparison. |
Function Summary¶
|
Get bin centers given bin edges. |
|
Create arrays for edges and bin centers. |
|
Convert a set of variable width bins to arbitrary uniform bins. |
Reference¶
-
class
tdub.hist.
SystematicComparison
(nominal, up, down)[source]¶ Systematic template histogram comparison.
-
nominal
¶ Nominal histogram bin counts.
- Type
-
up
¶ Up variation histogram bin counts.
- Type
-
down
¶ Down variation histogram bin counts.
- Type
-
percent_diff_up
¶ Percent difference between nominal and up varation.
- Type
-
percent_diff_down
¶ Percent difference between nominald and down variation.
- Type
numpy.ndaray
-
static
one_sided
(nominal, up)[source]¶ Generate components of a systematic comparion plot.
- Parameters
nominal (numpy.ndarray) – Histogram bin counts for the nominal template.
up (numpy.ndarray) – Histogram bin counts for the “up” variation.
- Returns
The complete description of the comparison
- Return type
-
-
tdub.hist.
bin_centers
(bin_edges)[source]¶ Get bin centers given bin edges.
- Parameters
bin_edges (numpy.ndarray) – edges defining binning
- Returns
the centers associated with the edges
- Return type
Examples
>>> import numpy as np >>> from tdub.hist import bin_centers >>> bin_edges = np.linspace(25, 225, 11) >>> centers = bin_centers(bin_edges) >>> bin_edges array([ 25., 45., 65., 85., 105., 125., 145., 165., 185., 205., 225.]) >>> centers array([ 35., 55., 75., 95., 115., 135., 155., 175., 195., 215.])
-
tdub.hist.
edges_and_centers
(bins, range=None)[source]¶ Create arrays for edges and bin centers.
- Parameters
- Returns
numpy.ndarray
– the bin edgesnumpy.ndarray
– the bin centers
Examples
from bin multiplicity and a range
>>> from tdub.hist import edges_and_centers >>> edges, centers = edges_and_centers(bins=20, range=(25, 225))
from pre-existing edges
>>> edges, centers = edges_and_centers(np.linspace(0, 10, 21))
-
tdub.hist.
to_uniform_bins
(bin_edges)[source]¶ Convert a set of variable width bins to arbitrary uniform bins.
This will create a set of bin edges such that the bin centers are at whole numbers, i.e. 5 variable width bins will return an array from 0.5 to 5.5: [0.5, 1.5, 2.5, 3.5, 4.5, 5.5].
- Parameters
bin_edges (numpy.ndarray) – Array of bin edges.
- Returns
The new set of uniform bins
- Return type
Examples
>>> import numpy as np >>> from tdub.hist import to_uniform_bins >>> var_width = [0, 1, 3, 7, 15] >>> to_uniform_bins(var_width) array([0.5, 1.5, 2.5, 3.5, 4.5])