How can I do a fit with a custom function in PyROOT?

Hi,

you may also pass any python function (which you need to wrap in a class :slight_smile:) you want to minimize to ROOT.Fit.Fitter, see How to pass fcn func defined on python side to ROOT.Fitter? . In this was you may configure the fitter (minimizer) of your choice as you need.

testpyfit.py contains simple example how to use it:
How to pass fcn func defined on python side to ROOT.Fitter?

In your case you will need to define also some “Chi**2” (FCN) function which you need to construct separetely (this is the function being minimized) using your function_Frechet .

The adventage of this approach is that you may define also your "Chi2" as you need (necessity for some more advanced fitting, solving some more complicated problems where you need to have the settings under control). This may be seen also as disadventage in the case of simple fitting when some default choices may be fine (you don’t need to specify your chi2 in the case of “TF1 approach”).

Cheers,
Jiri