Skip to content
New issue

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

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

Already on GitHub? # to your account

fix: per-channel yield uncertainty contribution from staterror-staterror terms #324

Merged
merged 2 commits into from
Feb 9, 2022
Merged
Show file tree
Hide file tree
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
6 changes: 0 additions & 6 deletions src/cabinetry/model_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@ def yield_stdev(
symmetric_unc = (up_variations_ak[i_par] - down_variations_ak[i_par]) / 2
total_variance = total_variance + symmetric_unc**2

labels = model.config.par_names()
# continue with off-diagonal contributions if there are any
if np.count_nonzero(corr_mat - np.diagflat(np.ones_like(parameters))) > 0:
# loop over pairs of parameters
Expand All @@ -300,11 +299,6 @@ def yield_stdev(
corr = corr_mat[i_par, j_par]
# an approximate calculation could be done here by requiring
# e.g. abs(corr) > 1e-5 to continue
if (
labels[i_par][0:10] == "staterror_"
and labels[j_par][0:10] == "staterror_"
):
continue # two different staterrors are orthogonal, no contribution
sym_unc_i = (up_variations_ak[i_par] - down_variations_ak[i_par]) / 2
sym_unc_j = (up_variations_ak[j_par] - down_variations_ak[j_par]) / 2
# factor of two below is there since loop is only over half the matrix
Expand Down
2 changes: 1 addition & 1 deletion tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def test_integration(tmp_path, ntuple_creator, caplog):
[[11.898333, 7.283185, 7.414715, 7.687922]],
rtol=1e-4,
)
assert np.allclose(model_postfit.total_stdev_model_channels, [20.329756], atol=1e-4)
assert np.allclose(model_postfit.total_stdev_model_channels, [20.439750], atol=1e-4)
_ = cabinetry.visualize.data_mc(model_postfit, data, close_figure=True)

# nuisance parameter ranking
Expand Down
2 changes: 1 addition & 1 deletion tests/test_model_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def test_yield_stdev(example_spec, example_spec_multibin):
model, parameters, uncertainty, corr_mat
)
expected_stdev_bin = [[8.056054, 1.670629], [2.775377]]
expected_stdev_chan = [9.585327, 2.775377]
expected_stdev_chan = [9.596340, 2.775377]
for i_reg in range(2):
assert np.allclose(total_stdev_bin[i_reg], expected_stdev_bin[i_reg])
assert np.allclose(total_stdev_chan[i_reg], expected_stdev_chan[i_reg])
Expand Down