question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parameter bounds affect fits with fixed parameters

See original GitHub issue

Description

See this example:

import pyhf

spec = {
    "channels": [
        {
            "name": "SR",
            "samples": [
                {
                    "data": [10.0],
                    "modifiers": [
                        {"data": None, "name": "Signal_norm", "type": "normfactor"}
                    ],
                    "name": "Signal",
                },
                {"data": [50.0], "modifiers": [], "name": "Background"},
            ],
        }
    ],
    "measurements": [
        {
            "config": {
                "parameters": [
                    {"bounds": [[0, 5]], "inits": [2.0], "name": "Signal_norm"}
                ],
                "poi": "Signal_norm",
            },
            "name": "minimal_example",
        }
    ],
    "observations": [{"data": [65.0], "name": "SR"}],
    "version": "1.0.0",
}

ws = pyhf.Workspace(spec)
model = ws.model()
data = ws.data(model)

# pyhf.infer.hypotest(6.0, data, model, qtilde=True)  # this fails

pyhf.set_backend("numpy", pyhf.optimize.minuit_optimizer(verbose=False))
# the next two work, but result in identical values
print(pyhf.infer.hypotest(6.0, data, model, qtilde=True))
print(pyhf.infer.hypotest(7.0, data, model, qtilde=True))

The CLs value reported in the last two lines is identical. This seems to be related to the parameter bounds [0,5]. When increasing the range, the CLs values are different (as expected).

When uncommenting the first hypotest (using scipy), the minimization fails:

pyhf.exceptions.FailedMinimization: Positive directional derivative for linesearch

Expected Behavior

All fits succeed, and different CLs for any POI value. If the bounds are somehow still respected, a warning about parameters being outside the bounds (and scaled back to the bound) would be helpful.

Actual Behavior

Same CLs for POI values above bound, and scipy backend crashes.

Steps to Reproduce

See above, same behavior with 0.5.2 and master.

Checklist

  • Run git fetch to get the most up to date version of master
  • Searched through existing Issues to confirm this is not a duplicate issue
  • Filled out the Description, Expected Behavior, Actual Behavior, and Steps to Reproduce sections above or have edited/removed them in a way that fully describes the issue

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
lukasheinrichcommented, Oct 17, 2020

I’ve verified that the example from @alexander-held fails with a more interpretable error msg for all three cases in #1126 and once you adjust the bounds the CLs values behave as expected

0reactions
matthewfeickertcommented, Oct 18, 2020

@lukasheinrich this is great. I think we can say that PR #1126 fully addresses this Issue then.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Parameters - Bumps 0.9.0 documentation
Bumps fitting is centered on Parameter objects. Parameters define the search space, the uncertainty analysis and even the user interface.
Read more >
scipy - Fitting only one parameter of a function with many ...
The newly created function accepts only two arguments: x and a , whereas b is fixed to the value taken from the local...
Read more >
Bounded parameter distribution - Monolix - Lixoft
Bounded parameters in the interface. Starting from the 2019 version, it is possible to “extend” the logit distribution to be bounded in [a,...
Read more >
Parameter and Parameters - lmfit
A Parameter has a value that can either be varied in the fit or held at a fixed value, and can have lower...
Read more >
12.2. Parameters — xraylarch 0.9.51 documentation - CARS
During a fit, a Parameter's value may approach or even equal one of the bounds, but will never violate the boundary. It should...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found