RooAbsPdf::sigma not working well

Hello, I have problem to compute the standard deviation of a distribution. Example:

x = ROOT.RooRealVar('x', 'x', -100, 100)
m = ROOT.RooRealVar('m', 'm', 5)
s = ROOT.RooRealVar('s', 's', 0.5)
g = ROOT.RooGaussian('g', 'g', x, m, s)
print g.sigma(x).getVal()

it returns 1.77020587599e-23 (instead of 0.5). For bigger number of the width it works, maybe it is a numerical problem. I am using ROOT 6.02.


Yes, this is a numerical problem in the integration of the function to compute the sigma. You have set a range [-100,100] which is far too large compared to the sigma of the distribution (0.5). If you set something smaller (e.g. [-10,10] ) the result will be fine.
You could eventually try to use the more accurate Adaptive Gauss-Kronrod Integrator, by doing before:




Hello Lorenzo, the new integrator you suggest works without changing the range.

It would be good to have a warning when the algorithm is not able to reach the desired precision.