Comments (10)
Thanks @moralejo . I remember that this changed at some point to be consistent (see e.g. #1936).
Let's put this on the list for the next release.
from gammapy.
Hi,
the code is correct, but it returns the Poisson parameter of the background in the OFF region
Whereas the same formula in the documentation:
https://docs.gammapy.org/1.1/user-guide/stats/wstat_derivation.html
is used to obtain the Poisson parameter of the background in the ON region - that is what mu_bkg means in the documentation. So probably only the docs are wrong.
Here:
gammapy/gammapy/datasets/map.py
Lines 2121 to 2126 in c71cb47
the return of the function (for the whole OFF region) is scaled by alpha, to get the value for the ON region, so it seems correct.
It would anyway be worth that an expert checks it. I also think it would be better to use, for the background Poisson parameters, variable names which make it clear straightaway whether they refer to the ON region or to the OFF region.
from gammapy.
Thanks @moralejo! Which modifications would you propose to https://docs.gammapy.org/1.1/user-guide/stats/index.html#notations, to make the description more clear?
from gammapy.
Thanks @moralejo! Which modifications would you propose to https://docs.gammapy.org/1.1/user-guide/stats/index.html#notations, to make the description more clear?
Hi,
I would say
"mu_bkg: predicted background counts in the ON region" ( this is what it means here, since below we have mu_off = mu_bkg / alpha)
Then, for consistency, the function get_wstat_mu_bkg should either be called get_wstat_mu_off , or be modified to return mu_bkg (and the code using the function should be changed as well).
In the current documentation https://docs.gammapy.org/1.1/user-guide/stats/wstat_derivation.html (not sure if everywhere else) mu_bkg has the same meaning as in the glossary - ok!
But then the formulae here:
https://docs.gammapy.org/1.1/user-guide/stats/wstat_derivation.html#profile-likelihood
need fixing (they were taken from a reference in which mu_bkg meant what in gammapy is called mu_noff). These would be the changes (crosscheck is welcome):
One can add
from gammapy.
I think here:
https://docs.gammapy.org/1.1/user-guide/stats/wstat_derivation.html#special-cases
mu_bkg is used wrongly... it definitely should be mu_off in the likelihood formula.
Not sure if in the following lines it has consistently the same (wrong) meaning, I have to check it... Done, see below.
from gammapy.
There are also problems here:
https://docs.gammapy.org/1.1/user-guide/stats/wstat_derivation.html#goodness-of-fit
The Likelihood function is the same as before, with arguments:
So the correct arguments to get the absolute maximum likelihood are:
(and the same in the two formulae afterwards)
from gammapy.
In https://docs.gammapy.org/1.1/user-guide/stats/wstat_derivation.html#derivation-of-the-wstat-formula
Where it says "mu_src" it should be "mu_sig"
from gammapy.
https://docs.gammapy.org/1.1/user-guide/stats/wstat_derivation.html#final-result
https://docs.gammapy.org/1.1/user-guide/stats/wstat_derivation.html#special-cases
In the two formulae above, mu_bkg should become mu_bkg / alpha (or, equivalently, mu_off)
Should be:
from gammapy.
Last part...
Under https://docs.gammapy.org/1.1/user-guide/stats/wstat_derivation.html#special-cases:
Again, mu_bkg must be replaced above by mu_bkg / alpha
should become mu_bkg = [alpha / (alpha+1)] * n_off
(mu_bkg / alpha should replace mu_bkg above)
should rather be [alpha / (1+alpha)] n_on - mu_sig
After that, I think the rest is ok (the values of W)
from gammapy.
All that is just to make the doc page consistent with the meaning of mu_bkg in the glossary.
About the code: I saw no misuse of get_wstat_mu_bkg (the returned value is multiplied by alpha to get the actual mu_bkg). But I did not check anything else... it would be good if some expert can make sure that the computation of the goodness of fit is correct.
from gammapy.
Related Issues (20)
- gammapy.visualization.plot_distribution does not work with non-array representation of axes HOT 2
- Keyword argument in `FluxPoints.read` shares name with arbitrary keyword argument. HOT 2
- Implement an estimator for the computation of Dark Matter upper limits HOT 2
- WcsNDmap fill_by_coord creating strange wavy patterns in spectra HOT 1
- Fit.covariance fails with default optimize_result argument=None
- TypeError when np.isnan is called on strings (modelings.models.core, writing a model to disk) HOT 1
- A generalised 1D model HOT 1
- TemplateSpatialModel.__init__ does not check for nan values in input map HOT 1
- LabelMapAxis re-orders labels HOT 1
- EBLAbsorptionNormSpectralModel.read_builtin('finke') --> IORegistryError: Format could not be identified HOT 3
- `SpectrumDatasetOnOff.plot_fit` shows residuals only within `mask_safe` HOT 4
- Named arguments aren't checked for some functions (leading to fat-fingering bugs)
- Consider other types of sample interpolation
- Not able to reproduce spiral arms plot with Faucher model using radius and theta HOT 1
- 3PC model fallback when the "b free" fit is not available
- Add an `inverted` parameter on `Observations.select_time`
- Sorting events by time with `MapDatasetEventSampler` HOT 1
- Allow for dowloading dataset from external repository HOT 1
- 'release' not showing as number in new sphinx HOT 1
- Gammpy.org issues on mobile phone HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gammapy.