Custom modifiers: feedback and suggestions #2350
Replies: 3 comments 1 reply
-
Thanks very much @alexander-held. This is great feedback to have. I'll be offline for next week, but I hope that we can iterate on all of this in the very near future. |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm writing here because I wanted to try the custom modifier solution but I cannot import the add_custom_modifier function because: 'No module named 'pyhf.experimental''. I am using pyhf version 0.7.4. |
Beta Was this translation helpful? Give feedback.
-
After playing around with it, I also have the same questions as Alexander.
I am basically using the m2 parameters as 1 since - when writing 1 instead of a parameter - I am not able to build the model. |
Beta Was this translation helpful? Give feedback.
-
I gave the custom modifier implementation #1991 another try and have a few questions / suggestions I would like to provide here. I figured it might be useful to do that in a discussion where threads are possible and I did not want to clutter discussion in the PR.
How do I define a parameter that enters multiple different expressions?
Take this example:
This prints expected yields of$2\cdot (-1)^2$ .
[20. 16.]
, which makes sense given the scaling byIf you now uncomment the signal_linear part, the result is
[-9.8 -7.8]
. What I want here to happen is a result of[20, 16] + (-1)*[0.1, 0.1] = [19.9, 15.9]
. I am not sure if this is a bug in the implementation or me not using the feature correctly. Such setups should be fairly common in EFT scenarios.Understanding the implementation conceptually / potential streamlining
To me,
add_custom_modifier()
passed intomodifier_set
declares that there is a parameter with some name, and that parameter should be a free parameter in the fit. I can then go on and use this parameter in expressions. It’s not obvious to me why thetype
of such expression actually need to match what I initially defined, as opposed to just being a generic custom type that will always just work. Is there a need to couple them tightly? What I want is any expression to just be able to use any parameter ideally, but I understand I somewhere need to declare “free” parameters.Here is the way I think about this (the following is a proposed interface, not something that works right now):
You would declare which extra parameters you need, and then freely use them in any expressions for modifiers of a type matching some reserved keyword like
"custom_mod"
.This would strip out a lot of things that from a user perspective aren’t immediately useful and a bit harder to remember to write down. It’s also not clear to me how the current interface essentially has you define a custom modifier with a name you pick, but then what that modifier does still depends on the expression. That expression is still defined per entry of the modifier acting on a sample, so I’m not sure what that custom modifier actually means or why I’d need one with a second unique name.
Put differently, the current implementation feels like it mixes concepts of parameters and modifiers a bit: modifiers operate on samples and are controlled by parameters. Parameters are just degrees of freedom in the model (or expressions thereof, to me an expression would still feel more parameter-like than a modifier).
Beta Was this translation helpful? Give feedback.
All reactions