I noticed that the RMS for TH1 calculation gives wrong results in some cases.
I have a set of data (double) with values of 0.1 + epsilon, where epsilon is of the order of 10e-10; if I do tree->Draw (“values>>h(1000)”) I obtain an RMS of 2e-9, while if I do
tree->Draw (“values - 0.1>>h2(1000)”) I obtain an RMS of 1.5e-10.
The documentation of root says that RMS is computed as Sqrt((1/N)*(Sum(x_i-x_mean)^2))
which should be insensitive to such pattern. Then I browsed the code and I saw that the computation is done using mean(x^2) - mean(x)^2. I’m not sure if this is the origin of the loss of precision but at least there should be written the right formula in the doc (even if in most cases are the same, in scientific application the difference could matter).
In any case I suggest to add to TH1 a GetRMSSlow methods that loops on the bin using the normal formula, so that the best value can be queried if needed.
p.root (47.8 KB)