Skip to content

Commit

Permalink
docs: improve yield prediction index descriptions (scikit-hep#420)
Browse files Browse the repository at this point in the history
* improve description of the indices of yield predictions and uncertainties
  • Loading branch information
alexander-held committed Jul 5, 2023
1 parent 7f46f03 commit 5ece244
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/cabinetry/model_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ModelPrediction(NamedTuple):
Args:
model (pyhf.pdf.Model): model to which prediction corresponds to
model_yields (List[List[List[float]]]): yields per sample, channel and bin,
model_yields (List[List[List[float]]]): yields per channel, sample and bin,
indices: channel, sample, bin
total_stdev_model_bins (List[List[List[float]]]): total yield uncertainty per
channel, sample and bin, indices: channel, sample, bin (last sample: sum
Expand Down Expand Up @@ -393,9 +393,11 @@ def yield_stdev(

# log total stdev per bin / channel (-1 index for sample sum)
n_channels = len(model.config.channels)
total_stdev_bin = [total_stdev_per_bin[i][-1] for i in range(n_channels)]
total_stdev_bin = [total_stdev_per_bin[i_chan][-1] for i_chan in range(n_channels)]
log.debug(f"total stdev is {total_stdev_bin}")
total_stdev_chan = [total_stdev_per_channel[i][-1] for i in range(n_channels)]
total_stdev_chan = [
total_stdev_per_channel[i_chan][-1] for i_chan in range(n_channels)
]
log.debug(f"total stdev per channel is {total_stdev_chan}")

# save to cache
Expand Down Expand Up @@ -436,7 +438,7 @@ def prediction(
fit" otherwise)
Returns:
ModelPrediction: model, yields and uncertainties per bin and channel
ModelPrediction: model, yields and uncertainties per channel, sample, bin
"""
if fit_results is not None:
if fit_results.labels != model.config.par_names:
Expand Down Expand Up @@ -468,7 +470,8 @@ def prediction(
]

# calculate the total standard deviation of the model prediction
# indices: channel (and bin) for per-bin uncertainties, channel for per-channel
# indices: (channel, sample, bin) for per-bin uncertainties,
# (channel, sample) for per-channel
total_stdev_model_bins, total_stdev_model_channels = yield_stdev(
model, param_values, param_uncertainty, corr_mat
)
Expand Down

0 comments on commit 5ece244

Please sign in to comment.