Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: improve yield prediction index descriptions #420

Merged
merged 2 commits into from
Jul 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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