# Simultaneous fit

Hi,

I have a question about simultaneous fit.
Example,
I have 2 data sets, a(x, y) and b(x, y).
and user defined function “func” with 3 parameters par(0), par(1), and par(2).
Then, fit of 2 data sets, and get best values of par(0), par(1), and par(2) and chi2/ndf.
This means that I get 2 fitting lines (for a and b data).
The par(0,1,2) are for both a and b data sets and chi2/ndf is for both a and b data sets.
Would you tell me how to do simultaneous multi graph fitting?

e.g.)

a_data = new TGraphErrors(10);
b_data = new TGraphErrors(15);

Double_t func(Double_t *x, Double_t *par);

void main()
{

TF1 *intfunc_a = new TF1(“intfunc_a”, func, 0.0, 1.0, 3);
a_data->Fit(“intfunc_a”);

TF1 *intfunc_b = new TF1(“intfunc_b”, func, 0.0, 1.0, 3);
b_data->Fit(“intfunc_b”);

}

``````  |
|  *
|  ------ *         a_data
|    ---------  *
|       -----------  *
Y|
|  ----------------------       *
|    +
|  ---      +
|  --------       +        b_data
|     -------------      +
|   -----------------------     +
|
+-------------------------------
``````

------------------------ x

The above example is the independent fitting that means the fitting for a_data and fitting for b_data are separated.
And the parameters of a_data and the parameters of b_data are totally different, and chi2/ndf’s are different, too.
But, I want to get common parameters, means

par(0) for a_data = par(0) for b_data
par(1) for a_data = par(1) for b_data
par(2) for a_data = par(2) for b_data

and I want to know total chi2/ndf for (a_data + b_data).
So, this fitting is for minimizing total chi2.
The normalization constants (magnitude constant such as x 10, or x 100) are different for a_data and b_data.

I want to know how to do that.
Thank you!

see example in \$ROOTSYS/tutorials/fit/fitMultiGraph.C

Rene

Hi,

Thank you for your reply, however, the fitMultiGraph.C example is only ONE fitting line for
3 data sets. I want to get TWO fitting lines for 2 data sets using same parameters except
normalization constants (magnitude constants). How should I do for that?

Thank you,

How can you pretend to get two different lines with exactly the same function coefficients?

Rene

Hi,

For example,

y = a * f(x); (for a_data set)
y = b * f(x); (for b_data set)
f(x) = f( x, par(0), par(1), par(2),… );

a and b are normalization constants (magnitude constants),
so, we can draw two lines and the f(x) is same function and same parameters.
(actually, the constant a and b are also parameters for the fitting)
That’s why I say “different normalization constants” in previous message.

Would you tell me how to do for that?
Thank you!

Dear friends,

Please let me continue this old thread.
Also I’m very interesting in Nobu-san’s questions.

I prepared instant samples as below, I would like to know how to extract normalization factor ‘a_0’ and ‘parameters’ using same function throughout simultaneous fit when we add two independent experimental data sets, for example.

In short, the point is to get ‘a_0’ which satisfies only one 2nd order polynomial shape for both data distributions simultaneously.

Carefully guessing, this kind analysis would be very popular, but I can’t solve it. Please let me share your wisdom.

Regards,
Ha

``````
{

// dummy data point
double x1[5], y1[5], ye1[5];
for (int i=0; i<5; i++){
x1[i] = 2+i;
y1[i] = log(2+i) / 1000.;
ye1[i] = y1[i] / 3.;
}

double x2[5], y2[5], ye2[5];
for (int i=0; i<5; i++){
x2[i] = 5+i;
y2[i] = sqrt(2+i);
ye2[i] = y2[i] / 3.;
}

//
TCanvas *c = new TCanvas("c", "", 0, 0, 900, 300);
c.Divide(3,1);

c.cd(1);
TH2F *h1 = new TH2F("h1","", 2, 0.0, 10.0, 2, 0, 0.010);
h1->SetXTitle("x  ");
h1->SetYTitle("a_{0} f  ");
h1->Draw();
TGraphErrors *gr1 = new TGraphErrors(5, x1, y1, 0, ye1);
gr1->SetMarkerColor(4);
gr1->SetMarkerStyle(20);
gr1->Draw("SP+");

c.cd(2);
TH2F *h2 = new TH2F("h2","", 2, 0.0, 10.0, 2, 0, 10);
h2->SetXTitle("x  ");
h2->SetYTitle("f  ");
h2->Draw();
TGraphErrors *gr2 = new TGraphErrors(5, x2, y2, 0, ye2);
gr2->SetMarkerColor(2);
gr2->SetMarkerStyle(23);
gr2->Draw("SP+");

// combined simultaneous fit?
// decide a_0, par[0], par[1], and par[2]
// throughout simultaneous fit
c.cd(3);
TH2F *h3 = new TH2F("h3","", 2, 0.0, 10.0, 2, 0, 10);
h3->SetXTitle("x  ");
h3->SetYTitle("f  ");
h3->Draw();
TMultiGraph *mg = new TMultiGraph("mg","");