Skip to content
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

Implement scipy confidence method #2146

Merged
merged 4 commits into from May 21, 2019

Conversation

Projects
None yet
2 participants
@adonath
Copy link
Member

commented May 20, 2019

This PR implements a confidence_scipy method, that uses scipy.optimize.brentq to find the error boundaries given some TS difference.

@adonath adonath self-assigned this May 20, 2019

@adonath adonath added the feature label May 20, 2019

@adonath adonath added this to the 0.12 milestone May 20, 2019


actual = fp.table["norm_err"].data
assert_allclose(actual, [0.069966, 0.052617, 0.092854], rtol=1e-3)
assert_allclose(actual, [0.069966, 0.052617, 0.092854], rtol=1e-2)

This comment has been minimized.

Copy link
@registerrier

registerrier May 21, 2019

Contributor

Any idea why the results are sensitive to the platform used?
These tolerances are fine on my mac but not on the linux used by Travis CI?

This comment has been minimized.

Copy link
@adonath

adonath May 21, 2019

Author Member

No, I have no idea. I could not reproduce these fails locally, which makes it almost impossible to debug...I've actually committed this change to master (5bd1e1a) to get a green Travis build first. I'll remove it from this PR again, because it's unrelated...


def confidence(self, parameter, backend="minuit", sigma=1, **kwargs):
"""Estimate confidence interval.
Extra ``kwargs`` are passed to the backend.
E.g. `iminuit.Minuit.minos` supports a ``maxcall`` option.
For the scipy backend ``kwargs`` are forwared to `~scipy.optimize.brentq`. If the

This comment has been minimized.

Copy link
@registerrier

registerrier May 21, 2019

Contributor

'are forwarded'

This comment has been minimized.

Copy link
@adonath

adonath May 21, 2019

Author Member

Done

def __init__(self, function, parameters, parameter, ts_diff):
self.loglike_ref = function(parameters)
self.parameters = parameters
self.function = function

This comment has been minimized.

Copy link
@registerrier

registerrier May 21, 2019

Contributor

I would call it ts_function and ts_ref. Since most of the time this is 2*loglike

This comment has been minimized.

Copy link
@registerrier

registerrier May 21, 2019

Contributor

Note that the same function could be used to compute 2D confidence regions.
I would use a more specific name for the tested parameter(s).

This comment has been minimized.

Copy link
@adonath

adonath May 21, 2019

Author Member

Concerning the naming of the fit statistics I've made a reminder issue #2149.

@adonath adonath force-pushed the adonath:scipy_confidence branch from d8cad8e to abdd36a May 21, 2019

@adonath adonath merged commit 3d9345a into gammapy:master May 21, 2019

4 of 9 checks passed

Codacy/PR Quality Review Not up to standards. This pull request quality could be better.
Details
gammapy.gammapy Build #20190521.6 had test failures
Details
gammapy.gammapy (Test Python35) Test Python35 failed
Details
gammapy.gammapy (Test Windows35) Test Windows35 failed
Details
gammapy.gammapy (Test Windows37) Test Windows37 failed
Details
Scrutinizer Analysis: 14 updated code elements – Tests: passed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
gammapy.gammapy (DevDocs) DevDocs succeeded
Details
gammapy.gammapy (Lint) Lint succeeded
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.