Set precision of fit

I am doing fits with RooAbsPdf::fitTo(data, …). I am not satisfied with the precision of one variable, in particular I see that the fitted value changes if I restrict its range around the fitter value (of the previous fit).

How to change the precision on a variable?

HI,

I am not sure exactly what you mean. If your fit is not very stable it is caused by your model, and it is not by changing precision in the fitting will improve it.

Lorenzo

I expect the value to be 0 a I get something like 1E-6, then if I restrict the fitting window I get a smaller value (closer to zero). I think it is a reasonable behaviour. Is there a way to tell to RooFit that I want more precision on that parameter? Since minimization is an iterative procedure there should be a way.

1 Like

You can use the minimizer class and set the “eps”-value of the minimizer manually. Here’s an example in python (with “pdf” and “data” as input).

# NLL with extended term, constrains, and likelihood offset
nll = pdf.createNLL(data, RF.Extended(1), RF.Constrained(), RF.Offset(1))

# Manual minimization
minimizer = ROOT.RooMinimizer(nll)
minimizer.setVerbose(False)
minimizer.setMinimizerType("Minuit2")
minimizer.optimizeConst(True)
minimizer.setEps(1e-8)
minimizer.setStrategy(2)
minimizer.setPrintEvalErrors(1)
minimizer.setOffsetting(True)
minimizer.migrad()
minimizer.minos()

Is that what you meant?

[quote=“lukash”]You can use the minimizer class and set the “eps”-value of the minimizer manually. Here’s an example in python (with “pdf” and “data” as input).

# NLL with extended term, constrains, and likelihood offset
nll = pdf.createNLL(data, RF.Extended(1), RF.Constrained(), RF.Offset(1))

# Manual minimization
minimizer = ROOT.RooMinimizer(nll)
minimizer.setVerbose(False)
minimizer.setMinimizerType("Minuit2")
minimizer.optimizeConst(True)
minimizer.setEps(1e-8)
minimizer.setStrategy(2)
minimizer.setPrintEvalErrors(1)
minimizer.setOffsetting(True)
minimizer.migrad()
minimizer.minos()

Is that what you meant?[/quote]

Hello, thank you. Yes, more or less. I guess the important line is

minimizer.setEps(1e-8)

the point is that you have changed the property of the minimizer instance of ROOT.RooMinimizer, which I guess it is not the same instance used by RooAbsPdf::fitTo. I know I can implement fitTo in term of migrad(), minos(), … but there are some script I cannot change, that are using RooAbsPdf::fitTo. I guess there should be a global variable defining the precision of the minimizer used by fitTo.

Yes, sorry, I completely forgot to highlight the important line.
Can you try to change the default ROOT minimizer options?
In Python you could try

import ROOT
ROOT.Math.MinimizerOptions.SetDefaultPrecision(1e-8)

See also here for more options you can change.

[quote=“lukash”]Yes, sorry, I completely forgot to highlight the important line.
Can you try to change the default ROOT minimizer options?
In Python you could try

import ROOT
ROOT.Math.MinimizerOptions.SetDefaultPrecision(1e-8)

See also here for more options you can change.[/quote]

yes, I think this is what I need. Thank you.

By the way it is very difficult to understand something from this page: what is the definition of precision, tolerance, … what are they default values… ? Documentation is pretty empty.

1 Like