I haven’t been able to track down the body of DoFit in the Reference Guide (v5.22). Where is it defined for TGraph or TH1F?
Ultimately I’d like to fit 1D functions cast as TF1 to arrays of data points (rather than histograms), and was thinking of using TGraph for that. Is there a more direct and simple way of doing this, e.g. fitting directly an array of doubles without first casting them into a TGraph, without invoking Minuit methods explicitly? I believe in past versions of ROOT this could be done via methods in TMath which are no longer there.
the implementation is defined in the file hist/hist/src/HFitImpl.cxx
If you want to fit directly an array of doubles, you have two possibility:
create from the array of doubles directly a TGraph, using the constructor taking an array of doubles
use directly the classes ROOT:Fit::BinData and ROOT::Fit::Fitter of mathcore as it is done in the implementation of DoFit. I am attaching a simple example on how to do this.
The BinData method looks promising. What is the actual fitting method in the attached example?
I would like to use the Likelihood method with unbinned data. Can you set these options with the BinData class, or it actually applies internally some algorithm for binning the data into an effective histogram as the name suggests?
the method used is the least square (chi2) method.
In case you have Poisson statistics with your bin data you can make a binned likelihood fit, calling in the fitter class the method
fitter.LikelihoodFit(data, wf);
If you want to perform an unbinned fit, you need to use the ROOT::Fit::UnBinData class. In this case you have (in 1Dim) an array of only x[] values. You create then the class as following
ROOT::Fit::UnbinData data(n,x);
and the rest is the same as in the example I sent to you. The default method in this case is the unbinned maximum likelihood. Remember that when performing an unbinned fit, the fit function is a probability density function describing your data and must be normalized to one in the used fit range. If you need I can send you an example of the unbin case too.
In ROOT you cannot perform un-binned fit of TGraph, but you can do them starting from a TTree (TTree::UnbinnedFit)