I have a global fit which performs fit on different sub-range with different functions, and I noticed that at the connection, I have discontinuity (big variation). I wonder if there is a smart easy way to solve that. Shouldn’t the fit handle that?
For ex. as you can see in the plots:
btw the gray and black line I fit with an expo
btw the black and the red a gaussian
btw red and to the end a sum of gauss
and we can see that at the black and red line we have discontinuity.
My global fit look look this [*]:
… // get parameters from xx and par
if ( x<gray_line ) result = p0_left + p1_leftx + p2_leftpow(x,2) +
p3_leftpow(x,3) + p4_leftpow(x,4) +
p5_leftpow(x,5) + p6_leftpow(x,6) +
else if ( x<black_line ) result = exp( normExp_left + xslopeExp_left );
else if ( x<red_line ) result = normGaus1 * exp(-0.5pow(((x-meanGaus1)/sigGaus1_left),2) );
else result *= sumGaus(&x, pp);
do you have any idea how to do that or any other forum where I can ask to solve this problem?
the fitting procedure finds the minimum value of a certain function of the parameters (e.g. a likelihood) given a model and a dataset: it does not have any information about the first derivatives of the functional form of the model and their potential discontinuities.
If you want to avoid those, you should embed this constraint in your fit, e.g. with penalty terms in the likelihood i.e. increasing it when the derivatives differ or with a different model if the Physics of your problem allows you to do that.
thank you for your answer. Unfortunately I did not understood what you mean.
Could you please tell me how I can “embed this constraint in your fit, e.g. with penalty terms in the likelihood i.e. increasing it when the derivatives differ”. I’m just using a simple hist->Fit() method.
So far I plan to solve the equation at the discontinuity. For ex where the gauss and the exponential join, I could solve:
exp( normExp_left + xslopeExp_left ) =
normGaus1 * exp(-0.5pow(((x-meanGaus1)/sigGaus1_left),2) )
so I would get if I solve for normExp_left:
normExp_left = ln( normGaus1 * exp(-0.5pow(((x-meanGaus1)/sigGaus1_left),2) )) - xslopeExp_left
then I could used normExp_left directly in the fit. Would that make sense?
no I did not try this method, actually I do not want to rebuild a likelihood, I want to keep using the root simple fit method tools.
Maybe do you have another simple idea one how to achieve that?
No, I do not see any other trivial way of accomplishing this.
ok, thank you for your help.