It’s been a while since I’ve had to fit curves and I’m new to how Root does it. My issue is how to handle boundary conditions between two fit functions. Attached is my macro and a graphic showing my results. I do a Gaussian fit inside the peak, then a Lorentzian fit outside the peak. The two fits are discontinuous at the boundary.
Intuition tells me that I should define the requirement f(a) = g(a) and f’(a) = g’(a) in the definitions of the fit functions. But, this doesn’t seem to be that simple. I’m not sure how to proceed.
I’m sure @moneta will be able to help you
My original code, as you’ll see, uses an if else statement to compute one or the other function. I removed that and that has gotten rid of the discontinuity. However, the functions do not have a common maximum, which introduces a “bump” at the top.
Your data in the range -15<x<15 can be perfectly fitted by a simple function, see the attached macrofit1.C (19.1 KB)
Thank you! That was an excellent solution. I’m curious about parameter p, which is used in
Double_t D = abs(x - p)/p;
return p*exp(-pow(D,p)) + p;
Normally, in a gaussian, p would be 2, but you set it as less than two. Moreover, you use the absolute value, which I assume is because p is not 2. I have not seen this approach before.
Yes, it is not a gaussian. The peak in your data can not be fitted with one gaussian. But you can fit it with two gaussians, see the attached macrofit2.C (19.7 KB)
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.