# Tutorial fit/ErrorIntegral.C explanation

Dear All,

I need an explanation regarding the tutorial ErrorIntegral.C. From line 67 to line 76 the integral error is computed analytically. My question regards parameters “ic” “i0c” and “i1c” because I can figure out how they are computed from the fit function. I know that the fit error is something like the sum of the derivatives in respect to the fit parameters multiplied by the covariance coefficients, but in this tutorial I really can’t undestand how “ic” “i0c” and “i1c” are calculated.

Thanks in advance and best regards.

Filippo

@moneta is the author of this example. I guess he can help you.

Hello,

Looking at the tutorial ROOT: tutorials/fit/ErrorIntegral.C File Reference, after having compute the integral and its error using the integral and the integral error using the TF1 generic functions, we compute the integrals and its error analytically using the fact that the fitting function is `f(x) = p* sin(p*x)`.
Therefore we have:

• integral in [0,1] : `ic = p* (1-std::cos(p) )/p`
• derivative of integral with respect to p0:
`c0c = p * (std::cos(p) + p*std::sin(p) -1.)/p/p`
• derivative of integral with respect to p1:
`c1c = (1-std::cos(p) )/p`

and then we can compute the integral error using error propagation and the covariance matrix for the parameters p obtained from the fit

integral error : `sic = std::sqrt( c0c*c0c * covMatrix(0,0) + c1c*c1c * covMatrix(1,1) + 2.* c0c*c1c * covMatrix(0,1))`

I hope it is clear now, if not please let me know.

Note that if you can you should fit directly the function integrals (i.e. the number of events), so you will obtain a better estimate directly from the fit of the uncertainty.
This is possible in ROOT when using the `TF1NormSum` class, see the tutorial
https://root.cern.ch/doc/master/fitNormSum_8C.html

Cheers

Lorenzo

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