# Error Propagation in TF1 class

Dear Rooters,

I have a function y = f(x,a,b) with a and b being free parameters whose uncertainties are da and db, respectively. Does ROOT provide any function or method to calculate the uncertainty of y, namely dy?

I add some texts below to clarify my question.

Manually, dy can be calculated using the error propagation formula (the one right below the “Simplification” headline) (https://en.wikipedia.org/wiki/Propagation_of_uncertainty). However it requires the derivative of f as a function of a and b.

For instance, assume that y = a*x + b;

The derivative of f as a function of a = x;

The derivative of f as a function of b = 1;

So, dy = sqrt((x^2da^2 + 1^2db^2)).

In this case, things seem very simple.

BUT

What if the function f is much more complicated? The derivative of f as a function of its parameters would have a very complicated form. Normally, I use the Monte Carlo method as follows.

I select random values of a and b within the range [a-da : a+da] and [b-db:b+db], respectively, then I calculate f and store it as y1.

Then I repeat N-1 times to get y2, y3, …, yN.

Finally, I calculate standard deviation of {yi} with i=1,N and consider it as dy.

This procedure is, however, slow!!!

SO my question is: Does ROOT provide a function or method that help me to solve the problem without doing calculus on the derivative or writing Monte Carlo code myself?

Thank you.

Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided

1 Like

Hi,

The TF1 class provides the derivative with respect to the parameter with the function TF1::GradientPar
https://root.cern.ch/doc/master/classTF1.html#a837da0f3735bc3ce18b9995dbacdc958

Often the parameter uncertainties are correlated, so you need to provide as well a covariance matrix of the parameters. If the uncertainty are coming from a previous fit, you can retrieve the covariance matrix from the fit result

Best regards

Lorenzo

1 Like

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