Iteration limit reached when using histosys modifier.
See original GitHub issueSummary
Hello everyone,
First of all let me thank you for the wonderful package. As a PhD student playing with LHC data for the first time, it is really helpful.
I would like to take into account a systematic uncertainty in my signal, to do that I tried to add the histosys modifier to my signal in addition to the normfactor for signal strength and the uncorr_bkguncrt for my background.
For some reason this caused pyhf.infer.hypotest to be stuck in a loop and raise an iteration limit exception (it also prints a lot of “nan” in the error report for the function to minimize, its jacobian and minimum).
I tried replacing histosys by shapesys and it seems to work normally.
Am I doing something wrong ? Is this a bug? Can you suggest a workaround for what I am trying to do?
Many thanks
OS / Environment
Ubuntu 20.04
Steps to Reproduce
mod = {
"channels": [
{ "name": "singlechannel",
"samples": [
{ "name": "signal",
"data": list(signal),
"modifiers": [{ "name": "mu", "type": "normfactor", "data": None},
{ "name": "mod_name", "type": "histosys", "data": {"hi_data": list(hi), "lo_data": list(lo)} }]
},
{ "name": "background",
"data": list(backgr),
"modifiers": [ {"name": "uncorr_bkguncrt", "type": "shapesys", "data": list(b_err)} ]
}
]
}
],
"observations": [
{ "name": "singlechannel", "data": list(obs) }
],
"measurements": [
{ "name": "Measurement", "config": {"poi": "mu", "parameters": [{"bounds": [[0, 1e+6]],"inits": [1.0], "name": "mu"}]} }
],
"version": "1.0.0"
}
File Upload (optional)
No response
Expected Results
A p-value.
Actual Results
fun: nan
jac: array([nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan])
message: 'Iteration limit reached'
nfev: 2999989
nit: 100000
njev: 100000
status: 9
success: False
x: array([nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan])
Traceback (most recent call last):
File "/mnt/c/pyhf/optimize/mixins.py", line 49
assert result.success
AssertionError
pyhf Version
0.62
Code of Conduct
- I agree to follow the Code of Conduct
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)

Top Related StackOverflow Question
Thank you so much! That wes exactly it. A simple
pip install scipy --upgradelater (from version 1.5.4), and it now works fine.Glad to hear it! 🙂 The reason I suspected
scipywas because the error was coming from the minimizer failing to converge, and there isn’t much in terms ofpyhfcode there.Though maybe it was actually a bug in an older version of NumPy (SciPy imposes both lower and upper limits on NumPy) or an interaction between NumPy and SciPy, as if I use
scipy==1.5.4I can still get it to pass: