-
Notifications
You must be signed in to change notification settings - Fork 83
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
feat: Add kwarg for AsymptoticCalculator base distribution #993
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look fine. Additional docstrings are needed to describe the new APIs. Otherwise, most of my concern is on the description:
In the standard brazil band plot ROOT HypotestInverter produces, there is a bit of an imprecision as the expected limits are calculated in
$mu^/sigma$ space but for significant upward fluctuations it returns p-values that are not actually realizable with any data since if$expected µ^ > µ$ the test stat can at most be the one returned for$µ=0$ that in turn means that the p-value is capped at $$
I don't follow this logic. Let's suppose, for example, scanning [0, 10]
, then if
Codecov Report
@@ Coverage Diff @@
## master #993 +/- ##
=======================================
Coverage 97.49% 97.49%
=======================================
Files 63 63
Lines 3749 3758 +9
Branches 535 537 +2
=======================================
+ Hits 3655 3664 +9
Misses 55 55
Partials 39 39
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
f97c9a6
to
e3275ff
Compare
512a420
to
f3aaad9
Compare
f3aaad9
to
9125564
Compare
@lukasheinrich I rebased this but have a pre-rebase version at We should discuss all of this again, but as we've introduced import pyhf
import pyhf.contrib.viz.brazil as barzil_band
import numpy as np
import matplotlib.pyplot as plt
model = pyhf.simplemodels.hepdata_like(
signal_data=[20.0], bkg_data=[50.0], bkg_uncerts=[7.0]
)
data = [70.0] + model.config.auxdata
poi_vals = np.linspace(0, 2.5)
results = [
pyhf.infer.hypotest(
test_poi, data, model, return_expected_set=True, calc_base_dist="normal"
)
for test_poi in poi_vals
]
fig, ax = plt.subplots()
barzil_band.plot_results(ax, poi_vals, results)
fig.savefig("base_dist_normal.png")
results = [
pyhf.infer.hypotest(
test_poi, data, model, return_expected_set=True, calc_base_dist="clipped_normal"
)
for test_poi in poi_vals
]
fig, ax = plt.subplots()
barzil_band.plot_results(ax, poi_vals, results)
fig.savefig("base_dist_clipped_normal.png")
The tests pass also beyond having to fixup doctest, so I think this is moving in the right direction. |
9125564
to
a1c0e4d
Compare
This PR also addresses some of Issue #1268, which while not the goal is nice. 👍 |
In addition to the APIs being updated the docstring for pyhf/src/pyhf/infer/calculators.py Lines 166 to 182 in 9d56349
should also get fixed up, as |
@kratsg @lukasheinrich This PR still needs to address the docstring requests that @kratsg and I made, but beyond that I think is ready for review. If you both make comments I will implement anything else that needs to get taken care of. 👍 |
Also maybe worth discussing if the changes to the |
can't aprrovemy own PR but thanks for rebasing. lgtm. |
As kwargs are now used it is easier to just add a "base_distr" keyword arg rather than adding a calc_kwargs specifically.
Seems more explicit, to Feickert at least
The bool qtilde is now no longer used and so should be removed
da9cbdd
to
0c1a0e1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will continue discussion in #1310 to not hold up this PR any longer.
Description
Resolves #1159
In the standard brazil band plot ROOT HypotestInverter produces, there is a bit of an imprecision as the expected limits are calculated in$\hat{\mu}/\sigma$ space but for significant upward fluctuations it returns p-values that are not actually realizable with any data since if expected $\hat{\mu} > \mu$ the test stat can at most be the one returned for $\mu=\hat{\mu}$ , namely $q_\mu = 0$ , that in turn means that the p-value is capped at $\mathrm{CLs}_\mathrm{obs}$ .
For compatibility and recognizability the default behavior is unchanged but it's now possible to get the correct asymptotic bahaviorr with
calc_kwargs = {'base_dir': 'clipped_normal'}
ReadTheDocs build: https://pyhf.readthedocs.io/en/clipped_expected/api.html#inference
pyhf.infer.calculators.AsymptoticTestStatDistribution
pyhf.infer.calculators.AsymptoticCalculator
pyhf.infer.calculators.ToyCalculator
Checklist Before Requesting Reviewer
Before Merging
For the PR Assignees: