pyhf and TRexFitter errors missmatching #2045
-
Hello everyone! fit values are consistent for both softs, but errors are missmatched.
Fit provided for the same nuisance params, and same missmatching for data fit case
(another channel)
I have no idea what to do with it, or is it normal? also my pyhf code def make_model(channel_list):
spec["channels"] = [c for c in spec["channels"] if c["name"] in channel_list]
w = pyhf.Workspace(spec)
wstat = w
m = wstat.model(
measurement_name="OBS_FULL_FIT_VVV",
modifier_settings={
"normsys": {"interpcode": "code4"},
"histosys": {"interpcode": "code4p"},
},
)
d = wstat.data(m)
return wstat, m, d
def fitresults(chanel, constraints=None):
_, model, data = make_model(chanel)
pyhf.set_backend("numpy", pyhf.optimize.minuit_optimizer(verbose=True, errordef=0.5, tolerance=0.01))
constraints = constraints or []
init_pars = model.config.suggested_init()
fixed_params = model.config.suggested_fixed()
bounds = model.config.suggested_bounds()
bounds[model.config.poi_index] = [-5, 5]
for idx, fixed_val in constraints:
init_pars[idx] = fixed_val
fixed_params[idx] = True
result = pyhf.infer.mle.fit(
data,
model,
init_pars=init_pars,
fixed_params=fixed_params,
par_bounds=bounds,
return_uncertainties=True,
)
bestfit = result[:, 0]
errors = result[:, 1]
return model, data, bestfit, errors
def asimov_fitresults(chanel, constraints=None):
_, model, data = make_model(chanel)
pyhf.set_backend("numpy", pyhf.optimize.minuit_optimizer(verbose=True, errordef=0.5, tolerance=0.01))
constraints = constraints or []
init_pars = model.config.suggested_init()
fixed_params = model.config.suggested_fixed()
bounds = model.config.suggested_bounds()
bounds[model.config.poi_index] = [-5, 5]
for idx, fixed_val in constraints:
init_pars[idx] = fixed_val
fixed_params[idx] = True
mu_test = 1
as_data = pyhf.infer.calculators.generate_asimov_data(
mu_test,
data,
model,
init_pars=init_pars,
fixed_params=fixed_params,
par_bounds=bounds)
result = pyhf.infer.mle.fit(
as_data,
model,
init_pars=init_pars,
fixed_params=fixed_params,
par_bounds=bounds,
return_uncertainties=True,
)
bestfit = result[:, 0]
errors = result[:, 1]
return model, data, bestfit, errors
spec = pyhf.readxml.parse('OBS_FULL_FIT_VVV/RooStats/OBS_FULL_FIT_VVV.xml', Path.cwd())
model,data,bestfit,errors = fitresults('three_lep_presel_atLeast_3jets')
print(model.config.channels, " ", model.config.poi_name, " ", bestfit[model.config.poi_index], " ", errors[model.config.poi_index]) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
@efemberg11 I don't think we can say much without having access to the workspaces and to your TRexFitter code. Have you tried using different values of If you were able to show agreement in an older version of |
Beta Was this translation helpful? Give feedback.
-
Hi @Efemberg, there are a few things here that contribute to the difference you see:
With a consistent
Thanks for sharing the setup in https://github.com/efemberg11/pyhf-Trexfitter_problem! For future reference, the replacement file ( |
Beta Was this translation helpful? Give feedback.
Hi @Efemberg, there are a few things here that contribute to the difference you see:
errordef
parameter should be set to1.0
, as the function being minimized is currently twice the NLL (#1006).TRExFitter
but notpyhf
.TRExFitter
and [-5, 5] forpyhf
(not far enough away from the best-fit points, so this matters a bit here).With a consistent
errordef
, bounds of [-7, 7] and without MINOS the results match:TRExFitter
: 1 +/- 1.47738pyhf
: 1.000000013607906 +/- 1.4773487926962865TRExFitter
: -2.80028 +/- 1.43134pyhf
: -2.8002789622557653 +/- 1.4312962850983402Thanks fo…