Skip to content

Attaching modifiers twice to a sample #2059

Description

@alexander-held

Summary

When adding a modifier twice to a sample, only one instance is used. For normfactor modifiers this could in principle be something a user would want to do on purpose (as a simplified way to scale different samples by mu and sqrt(mu), see also #850). It might be useful to catch such specifications and warn users about the current behavior.

OS / Environment

n/a

Steps to Reproduce

import pyhf

spec = {
    "channels": [
        {
            "name": "SR",
            "samples": [
                {
                    "data": [25.0],
                    "modifiers": [
                        {"data": None, "name": "mu", "type": "normfactor"},
                    ],
                    "name": "Signal",
                },
            ],
        }
    ],
    "measurements": [
        {"config": {"parameters": [], "poi": "mu"}, "name": "minimal_example"}
    ],
    "observations": [{"data": [35.0], "name": "SR"}],
    "version": "1.0.0",
}


def fit(spec):
    ws = pyhf.Workspace(spec)
    model = ws.model()
    data = ws.data(model) + model.config.auxdata
    print(pyhf.infer.mle.fit(data, model))


# fit with one modifier
fit(spec)

# add a second POI
spec["channels"][0]["samples"][0]["modifiers"].append(
    {"data": None, "name": "mu", "type": "normfactor"}
)
fit(spec)

File Upload (optional)

No response

Expected Results

warning or correct application of two POIs on the sample

Actual Results

[1.40000145]
[1.40000145]
# second modifier is ignored

pyhf Version

pyhf, version 0.7.0

Code of Conduct

  • I agree to follow the Code of Conduct

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinguser requestRequest coming form a pyhf user

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions