Skip to content

Commit 5ece244

Browse files
docs: improve yield prediction index descriptions (#420)
* improve description of the indices of yield predictions and uncertainties
1 parent 7f46f03 commit 5ece244

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/cabinetry/model_utils.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class ModelPrediction(NamedTuple):
2323
2424
Args:
2525
model (pyhf.pdf.Model): model to which prediction corresponds to
26-
model_yields (List[List[List[float]]]): yields per sample, channel and bin,
26+
model_yields (List[List[List[float]]]): yields per channel, sample and bin,
2727
indices: channel, sample, bin
2828
total_stdev_model_bins (List[List[List[float]]]): total yield uncertainty per
2929
channel, sample and bin, indices: channel, sample, bin (last sample: sum
@@ -393,9 +393,11 @@ def yield_stdev(
393393

394394
# log total stdev per bin / channel (-1 index for sample sum)
395395
n_channels = len(model.config.channels)
396-
total_stdev_bin = [total_stdev_per_bin[i][-1] for i in range(n_channels)]
396+
total_stdev_bin = [total_stdev_per_bin[i_chan][-1] for i_chan in range(n_channels)]
397397
log.debug(f"total stdev is {total_stdev_bin}")
398-
total_stdev_chan = [total_stdev_per_channel[i][-1] for i in range(n_channels)]
398+
total_stdev_chan = [
399+
total_stdev_per_channel[i_chan][-1] for i_chan in range(n_channels)
400+
]
399401
log.debug(f"total stdev per channel is {total_stdev_chan}")
400402

401403
# save to cache
@@ -436,7 +438,7 @@ def prediction(
436438
fit" otherwise)
437439
438440
Returns:
439-
ModelPrediction: model, yields and uncertainties per bin and channel
441+
ModelPrediction: model, yields and uncertainties per channel, sample, bin
440442
"""
441443
if fit_results is not None:
442444
if fit_results.labels != model.config.par_names:
@@ -468,7 +470,8 @@ def prediction(
468470
]
469471

470472
# calculate the total standard deviation of the model prediction
471-
# indices: channel (and bin) for per-bin uncertainties, channel for per-channel
473+
# indices: (channel, sample, bin) for per-bin uncertainties,
474+
# (channel, sample) for per-channel
472475
total_stdev_model_bins, total_stdev_model_channels = yield_stdev(
473476
model, param_values, param_uncertainty, corr_mat
474477
)

0 commit comments

Comments
 (0)