Same parameters for two different fit functions

Dear ROOTERs,

I have a problem with my fit function. I have two different fit functions for different data ranges and I would like to make some parameters the same for both functions.
I have made a small example with two different Gaussian functions. In principle I want the norm or the standard deviation to be the same after the fitting process but optimized for both data ranges at the same time. Of course, in this simple example I could use a single fit function but this is not possible in my application.

Hope someone has a solution for this problem.
two_Gaussians.c (957 Bytes)

Hi,

what you are trying to carry out is a simultaneous fit.
You can have a look to root.cern.ch/root/html/tutorial … Fit.C.html

Cheers,
Danilo

Thanks for the hint Danilo. The simultaneous fit example is very nice, I almost solved my problem with it but still wouldn’t be the perfect solution. I guess the example is more for a combined fit for two different data sets.

I hoped to hear that there is a solution like:

Double_t combined(Double_t *x, Double_t *par){
return gaus1(x,par)+gaus2(x,&par[3,4,2])
}
what should mean that the standard deviation for both is the same. However, I finally found that my function is not as complicated as expected :^o and solved my problem like this:

Double_t complicated_function(Double_t *x, Double_t *par){
Double_t val;
if (x[0]<par[0]) val=function1(x[0],par[i]);
else val= function2(x[0],par[i]);
if (x[0]<par[1]) return val+function3(x[0],par[i]);
else return val+function4(x[0],par[i])
}

where [i] is an arbitrary set of mixed parameters.

Thanks,
Don