Sum of weight * weight * X * X in TH1

Hello everyone,
TH1 histograms keep track of the total sum of weights, of the total sum of squares of weights, of the total sum of weight * X, and of the total sum of weight * X * X. These can be accessed via TH1::GetStats.

Is the total sum of weight * weight * X * X also computed? It is useful when one wants to evaluate the variance of weight*X.

Thanks a lot,
Claudio

Hi,
The histogram does not store the sum of weight * weight * X * X. But, why would you need to for ? One is interested in the weighted variance of X not the variance of weight * X.
If this is what you need fill an histogram with (weight * x) as new variable X

Cheers

Lorenzo

Thank you Lorenzo for your reply!

I understand this may be a niche application, but when computing a weighted average it can be useful to evaluate the numerator, sum w_i x_i, and the denominator, sum w_i, separately, and to combine them at a later stage. To keep track of uncertainties, this requires the variance of weight * x to be evaluated.

If this is what you need fill an histogram with (weight * x) as new variable X

Indeed, this seems to be the best solution given what ROOT currently does.

Thanks,
Claudio

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