Differences between values and their fitting function

I have data and I made fitting function with TF1 class. And I want to subtract each of values from fitting function. I think that

  1. Get y value of fitting function.
  2. Subtract each of values from y value of fitting function.
    But I don’t know how I get the y value and this method is inefficient.
    And I feel that there is a function which find this. Is there any function which I am finding?

What you’re after is called “residuals”. See for instance https://root.cern/doc/master/ratioplot2_8C.html Does that do what you’re after?

Are the residuals used in case of histogram? I want to find residuals between function and fitting function. But, I could find only histograms in the web.

You can simply iterate over the histogram bins, use hist->GetBinContent(ibin), and subtract the fit functions func->Eval(hist->GetBinCenter(ibin)). Does that do it? And yes, the graph in the tutorial’s lower plot shows the residuals.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.