scikit-hep / iminuit

Jupyter-friendly Python interface for C++ MINUIT2
https://scikit-hep.org/iminuit
Other
285 stars 76 forks source link

Including parametrized parameter ala LMfit #638

Closed fschlueter closed 3 years ago

fschlueter commented 3 years ago

Hi all,

I was wondering if it is possible (and I missed it so far) or if it is planed to included some functionality to parametrize parameters (to other freely, fitted parameter). Something like this is possible with LMfit (class Parameter with "expr" argument https://lmfit.github.io/lmfit-py/parameters.html#lmfit.parameter.Parameter). Of course one can write custom cost functions and wrappers to achieve the same. but this often ends in a lot of ugly code. For R&D one wants to quickly change the parametrization or free/fix the parameter completely.

Is that in principle possible with iminuit or do you see "red flags"

Best

HDembinski commented 3 years ago

Hi @fschlueter, while techically everything is possible, the scope of iminuit ends with providing cost functions. We do not plan to include a framework to build statistical models. What you describe with the Parameter class sounds like model-building (please correct me if I am wrong, a simple example would help to understand your request).

Note that iminuit supports several cost functions in iminuit.cost, you only need to provide the pdf, cdf, or the function that predicts the y-values (in case of a least-squares fit). Building the model from scratch is easy and it allows you to use your framework of choice to make a fast model (I recommend numba).

HDembinski commented 3 years ago

I am closing this issue, but feel free to reopen in case I misunderstood you.