Problem with TH1I::GetMean()

Attached is a file containing a histogram, that I’m having problems with. It has no entries above 20, yet when I change the range (using SetRangeUser) from 0-200 down to 0-198 the mean increases from 3.268 to 3.768. I checked that there are no overflow bins, nor any negative entries, so I’m very puzzled about what is wrong with the histogram. If I calculate the mean by hand by looping over all the bins (up to 200), then I get a mean of 3.268. I’m using ROOT v5.18.

If anyone could take a look and tell me what is wrong with the histogram it would be very much appreciated! A postscript: if I save the histogram as a script, then afterwards there are no problems with it.
test1.root (3.86 KB)

As soon as you select a subset of the original range, the statistical quantities are recomputed from the bin contents and assuming the centre of the bins.
The algorithm could be optimized in case the excluded bins are empty.

Rene