Last active
October 29, 2020 03:42
-
-
Save matthewfeickert/e34dac35ff72c4a98d71980041a83fb4 to your computer and use it in GitHub Desktop.
David Rousso toys notebook converted to script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import pyhf | |
stopRHadron_spec = { | |
'channels': [ | |
{ | |
'name': 'channel1', | |
'samples': [ | |
{ | |
'data': [1.364790054231882], | |
'modifiers': [ | |
{'data': None, 'name': 'lumi', 'type': 'lumi'}, | |
{'data': None, 'name': 'mu_Sig', 'type': 'normfactor'}, | |
{ | |
'data': {'hi': 1.228925751097454, 'lo': 0.7710742489025461}, | |
'name': 'ucs_StopRHadron_1100_100000', | |
'type': 'normsys', | |
}, | |
], | |
'name': 'StopRHadron_1100_100000', | |
}, | |
{ | |
'data': [0.43], | |
'modifiers': [ | |
{ | |
'data': [0.16], | |
'name': 'staterror_channel1', | |
'type': 'staterror', | |
} | |
], | |
'name': 'Bkg', | |
}, | |
], | |
} | |
], | |
'measurements': [ | |
{ | |
'config': { | |
'parameters': [ | |
{ | |
'auxdata': [1.0], | |
'bounds': [[0.5, 1.5]], | |
'inits': [1.0], | |
'name': 'lumi', | |
'sigmas': [0.017], | |
} | |
], | |
'poi': 'mu_Sig', | |
}, | |
'name': 'meas', | |
} | |
], | |
'observations': [{'data': [0.0], 'name': 'channel1'}], | |
'version': '1.0.0', | |
} | |
def main(): | |
pyhf.set_backend("jax") | |
workspace = pyhf.Workspace(stopRHadron_spec) | |
model = workspace.model() | |
observations = [0] | |
data = observations + model.config.auxdata | |
print(f"data: {data}") | |
test_poi = 1.0 | |
print("# Asymptotics\n") | |
cls_obs, cls_exp = pyhf.infer.hypotest( | |
test_poi, data, model, return_expected_set=True, calctype="asymptotics" | |
) | |
print(f"cls_obs: {cls_obs}") | |
print(f"cls_exp: {cls_exp}") | |
n_toys = 10000 | |
print("\n# Toys") | |
cls_obs, cls_exp = pyhf.infer.hypotest( | |
test_poi, | |
data, | |
model, | |
return_expected_set=True, | |
calctype="toybased", | |
ntoys=n_toys, | |
) | |
print(f"\ncls_obs: {cls_obs}") | |
print(f"cls_exp: {cls_exp}") | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
below I show brazil bands for scans of µ \in [0.1, 5, 50]
asymptotics
toys (1k toys per µ)