New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Background systematics as a nuisance parameter #3955
Comments
Merci! We will respond to your issue shortly. In the meantime, try |
Thanks @moralejo for the feature proposal! Alternatively one can also fit the background normalization and spectral shape using various built-in models, such as: This effectively treats the background norm as a nuisance parameter, however without the prior information. Taking into account the a e.g. Gaussian prior distribution is technically already possible, by implementing a custom class MyMapDataset:
"""My custom map dataset"""
def stat_sum(self):
stat = super().stat_sum() # Summed -2 * log Poisson likelihood
stat += (self.background_model.norm.value - mean) ** 2 / sigma ** 2
return stat Handling priors on parameters is definitely on the feature list for upcoming versions of Gammapy. |
Thanks, @adonath. But I am not sure I understand (I have quite limited experience with gammapy, sorry): is that background normalization independent for on and off? (in point-like analysis). That is what we really need - but then the prior (defining how much the backg can differ between the on and off, e.g. 1%) is absolutely needed. Without prior for that background difference, the excess, no matter how large, could always be fitted by a different background in on and off, right? |
Thanks @moralejo, I now understand better what you are trying to achieve.
No it isn't. In case of a on-off analysis, the background in the on region is "hardwired" to alpha * n_off and the "wstat" (on/off) Poisson likelihood. Currently there is no simple mechanism to introduce an additional scaling factor to the background model in the As the likelihood function including the priors looks different I assume the approach of analytically "marginalizing" over the background as done in "wstat" does not work anymore either. Do you have an example / write up of what the likelihood function looks like in your use case? BTW: You can now write math expressions in GitHub Markdown https://github.blog/changelog/2022-05-19-render-mathematical-expressions-in-markdown/ |
I was thinking on the typical point-like analysis we do for LST-1 data, using wobble data, with one or more off positions. As of now, the Poisson parameter of the background (say, mu_bg) is a nuisance parameter which enters both the on and off likelihood terms, as The idea is to make the normalization Of course this will complicate finding the best value for |
Thanks @moralejo, now I think I understood what you are trying to achieve. As far as I can tell there is currently no simple way to achieve something like this in Gammapy, however it is probably still possible. Maybe @registerrier has a more concrete idea here. |
Indeed, we had a conversation in Bologna about this - I should have mentioned it. I think it can be done, but since the two nuisance parameters For non-point-like analysis I guess the equivalent feature would be a 2D background model in which a certain (relative) level of deviations w.r.t. a (possibly symmetric) template are allowed, with those deviations being limited by a prior (e.g. 1% std dev gaussian or whatever). It is just a way of introducing a realistic limit to our knowledge of the background (which otherwise could be made, in terms of relative uncertainty, arbitrarily small just by adding more statistics). |
Thanks @SeiyaNozaki! As far as I understood you basically implemented a ring background estimation method for spectral analysis. This is a long open feature request in Gammapy (#1112). It would be great to support a However in general it is different from the what @moralejo proposed, which requires an additional prior on the |
Hi @adonath
Good to know, let me implement it based on this implementation later!
Yes, let's say this is an alternative way to estimate background level based on signal-less region for on/off samples. Please let me explain this way again next Monday at the LST-focused slot during the coding sprint. |
Hi @adonath, below is a proposal on how to introduce both the background rate and the on/off normalization as nuisance parameters. I have tested the approach on a notebook (where can I share it?) and it seems to work well. We measure We will consider Given Deriving w.r.t. we just use "g" below to simplify the notation: Solving the equation above with a fixed Now derive w.r.t. In both equations only one of the solutions is sensible. To find both alpha and mu we can do a few steps (find |
Form the Gammapy side this would require adapting our likelihood API. I think we should give us at least 0.5 year for that. I'll set the 1.2 milestone here. |
I think that perhaps this might be implemented in a simpler (and probably nearly equivalent) way. If the likelihood terms for well-populated bins (= those in which the background systematics are relevant) are written in gaussian approximation, wouldn't it be enough to replace the standard deviation of the gaussian terms for the on region (which would originally be sqrt(mu + g(theta)) by a larger value, say, sqrt(1.01*mu + g(theta))? - for a ~1% background systematic uncertainty. The mean of the gaussian should stay unchanged, i.e. mu + g(theta) |
Thanks @moralejo! We have started to work on collecting use-cases for extended likelihood functions / priors. @nbiederbeck will present some first ideas for a new API at the next coding sprint and then we will write the proposal up in a PIG (proposal for improving Gammapy). I hope this will happen within the next few weeks. Once we have a draft we will come back to you and ask for your feedback! |
At low energies, particularly in single-telescope analysis (or also in stereo, for weak sources observed in long periods) the gamma excess may be just a few percent of the residual background. In such cases, systematic errors in the background normalization factor (of, say, ~1%) would have a large effect in the estimated gamma-ray flux. This is currently not taken into account.
It would be good to include this uncertainty in gammapy's calculations. A possible way is to include the normalization factor as a nuisance parameter (with e.g. gaussian distribution, adding a term in the likelihood). It could be a energy-bin-wise nuisance parameter (although we might expect some correlations among neighboring bins).
The text was updated successfully, but these errors were encountered: