Logarithmic fitting problem

I have written a macro to plot data points. I want to fit the data points with interpolating logarithmic

TF1 *fitFunc = new TF1(“fitFunc”, “[0]*TMath::Log(x) + [1]”, -1, 110);
fitFunc->SetParameters(20, 10);

I tried changing SetParameters , but results are same . Any help ?

Could you please share at least your data points, otherwise is very difficult to help you.
The only thing I notice that maybe could affect the fit is your function range. Set the range to be positive, change the minimum from -1 to a positive value even very smaller like 1e-5

Or if your first points are negative you should change your TF1 to

TF1 *fitFunc = new TF1("fitFunc", "[0]*TMath::Log(x–[2]) + [1]", -1, 110);

in order to avoid the argument of the log function to be negative

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.