I am fitting a TGraphErrors() using a TF1() function.

auto g = new TGraphErrors(n,x,y,nullptr, err_y);
TFitResultPtr r = g->Fit(func, "WRS");

I am wondering how to obtain the mean uncertainty in the fitted function. I am unsure what the exact term for this in statistics is. It represents the average of two sigma bounds for each f(x). f = fit function, and x is the x-axis value.
To clarify a bit more the two red dashed lines around the fit

Is there any pre-defined functionality in ROOT for this?

Please share for any additional information from my side.
Thanks a lot.

Thanks for posting on the forum! Yes ROOT provides facilities to get the confidence interval of your fit. From the TFitResultPtr object you can call r->GetConfidenceIntervals(). See this tutorial for an example usage with plots.

Hi @vpadulan,
Thanks for your answer.
Correct me if am wrong, the GetConfidenceIntervals() only returns the confidence intervals at the points used for fitting, right ?

You are not calling any existing signature like this. I guess what you are trying to do is calling this signature ROOT: ROOT::Fit::FitResult Class Reference where x and ci are arrays but in your case they are not arrays so you should correct that.

Can you please help on how to get confidence intervals of unknown points n fitting range?

About this I am not sure, probably @moneta or @couet know. But in general, the tutorial shows you how to draw the line for the confidence intervals over the entire fit, if you only need to draw and not get the actual values.

Yes, the function you need for this is FitResult::GetConfidenceIntervals. You can compute the fitted function uncertainty (band) at the fitted points or on whatever points you provide. Afterwards you can create a TGraph from these points and using interpolation display as in the above figure. You can choose teh desired confidence value (e.g 95% as above) and also to re-normalize the uncertainty using the obtained fit chi-square. This is needed when you don’t have uncertainty on data points as above.

The normalization is automatically done when using option “W”, so it is not needed in this case. When fitting a TGraphErrors, and the errors are correctly estimated you might want not to apply this re-normalization.