# TH1::Fit, integral option Problem

Hello folks,

I’m trying to understand this:

option = “I” Use integral of function in bin, normalized by the bin volume,
instead of value at bin center

Shouldn’t I get the same fit-result, if I, e.g., merge two bins, for the same data?
Can someone give me a hint?

greetings and regards,
Stephan

``````void intfit(){

gStyle->SetOptFit();

double x[]={0,1,2,3,4,5,6,7,8,9,10};
TH1F *h = new TH1F("h","h",10,x);

double x2[]={0,1,2,3,4,6,7,8,9,10};
TH1F *h2 = new TH1F("h","h",9,x2);

h->Fill(0,0);
h->Fill(1,1);
h->Fill(2,2);
h->Fill(3,3);
h->Fill(4,4);
h->Fill(5,5);
h->Fill(6,6);
h->Fill(7,7);
h->Fill(8,8);
h->Fill(9,9);

h2->Fill(0,0);
h2->Fill(1,1);
h2->Fill(2,2);
h2->Fill(3,3);
h2->Fill(4,4);
h2->Fill(5,5);
h2->Fill(6,6);
h2->Fill(7,7);
h2->Fill(8,8);
h2->Fill(9,9);

TF1 *f = new TF1("f","[0]*x+[1]",0,10);

TCanvas *c = new TCanvas;
h->Fit(f,"I","",0,10);

TCanvas *c2 = new TCanvas;
c2->SetWindowPosition(10,600);
h2->Fit(f,"I","",0,10);

}``````

Hi,

This is expected because by merging bins you loose information and you decrease your number of degrre of freeedom of your fit

Lorenzo