icecube / pisa

Monte Carlo-based data analysis
http://icecube.github.io/pisa/
Apache License 2.0
19 stars 47 forks source link

Support iminuit 2.x for hypersurfaces and local fits #681

Closed atrettin closed 2 years ago

atrettin commented 2 years ago

This PR fixes issue #649 and adds iminuit as yet another option to the toolkit of the Analysis class. It can be dropped in place of local scipy optimization by setting local_fit_kwargs to a dictionary with the following content:

minuit_settings = {
    "errors": 0.1,  # initial Migrad step size, not very important
    "precision": 1e-14,  # default: double precision
    "tol": 0.1,  # default: 0.1
    "run_simplex": True  # run simplex before polishing the result with Migrad (default: False)
    "run_migrad": True  # run migrad (default: True). If `False`, runs only Simplex and exits
}

local_fit_kwargs = {
    "method": "iminuit",
    "method_kwargs": minuit_settings,
    "local_fit_kwargs": None  # minuit is a local optimization and therefore ends the recursion
}

The errordef option is automatically set depending on the type of loss function being optimized. When both Simplex and Migrad are run, Simplex stops at a relatively lax tolerance and the result is polished with Migrad.

philippeller commented 2 years ago

This PR looks fine to me, so will merge

mvprado0 commented 2 years ago

Hi, sorry, I wasn't sure how in depth I needed to check this, so I was still reading through it and running it. So far, everything looked good but I haven't finished looking through it.

philippeller commented 2 years ago

Hey @mvprado0 sorry I wasn't sure that you were still looking into it! I should have asked. Please let us know if you find any issues