# Histogram and Graph fits, different results!

Dear ROOTers,

Assume a histogram from 0 to 1023 with 1024 bins. Each number from 0 to 1023 has a specific value. Now, consider I draw a graph with the same amounts, with the exception that values for X axis changes to X+0.5 (since histograms only care the center of bins in fits). Now when I fit a line to graph and histogram I get different results:

“first” is a HISTOGRAM.
command: first->Fit(“pol1”,"","",TenPercent_first,SixtyPercent_first);
result:

Minimizer is Linear
Chi2 = 0.0130941
NDf = 11
p0 = -0.410958 +/- 1.7957
p1 = 0.0028866 +/- 0.0118169

“gr” is a GRAPH.
command: gr->Fit(“pol1”,"","",TenPercent_first,SixtyPercent_first);
result:

Minimizer is Linear
Chi2 = 0.000339396
NDf = 11
p0 = -0.344322 +/- 0.0632206
p1 = 0.00245905 +/- 0.000411738

Albeit these two fits do not differ significantly but they do at the end of some complex calculations. Can you tell me why these two fits are different?

Thanks

Try:
first->Fit(“pol1”,“W”,"",TenPercent_first,SixtyPercent_first); // “W” or “WW”

Therefore, TGraph fits the points by setting all the weights to 1 (cost function is the absolute distance of points to the fitted line rather than distance squared.), am I right?

The problem is that I get a better result using histogram than graph, that is:
first->Fit(“pol1”,"","",TenPercent_first,SixtyPercent_first);
and I want graph to have the same result as histogram and not the reverse, since I want to use a function at the end which I can only do it with graph and not with histogram. Is there anyway to force the graph-fit to give the same result as the histogram?

Best,