# What distribution does TH1::Sumw2() correspond to?

**URL:** <https://root-forum.cern.ch/t/what-distribution-does-th1-sumw2-correspond-to/39463>\
**Category:** Newbie\
**Created:** [May 17, 2020, 11:37pm UTC](https://root-forum.cern.ch/t/what-distribution-does-th1-sumw2-correspond-to/39463 "2020-05-17T23:37:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![eggsAndCoffee](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/ecb155/32.png) [@eggsAndCoffee](https://root-forum.cern.ch/u/eggsAndCoffee)\
**Post date:** [May 17, 2020, 11:37pm UTC](https://root-forum.cern.ch/t/what-distribution-does-th1-sumw2-correspond-to/39463/1 "2020-05-17T23:37:01Z")

</div>

I’m trying to understand what the motivation for TH1::Sumw2() is, and under what circumstances it actually properly represents the uncertainty on a histogram bin. From the documentation for [TH1::Sumw2()](https://root.cern.ch/doc/master/classTH1.html#aefa4ee94f053ec3d217f3223b01fa014), it is said that:

> The error per bin will be computed as sqrt(sum of squares of weight) for each bin.

**My question is, _why_ and _when_ does this apply?**

I would assume that typical use of a TH1 is to count “things” or “events”, often under a Poisson process. If the weight of each entry were 1, then the error in a bin turns out to be sqrt(bin content), and this makes sense. But if you now have a scenario where the weight of each entry is less than 1, say from Monte Carlo data where the weight represents a statistical weight, then is it appropriate to take the error as sqrt(sum of squares of weight)? I would think that, in the spirit of a Poisson-like process, the error should be sqrt(sum of weights). The calculated uncertainty in the former is much smaller than the calculated uncertainty in the latter generally, so I want to understand the difference.

So why use Sumw2()? What assumptions go into its use? Is it even **meant** to be used in the circumstance where I’ve described above, where you are counting simulated events with weights \< 1 but that would be Poisson otherwise?

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [May 18, 2020, 7:15am UTC](https://root-forum.cern.ch/t/what-distribution-does-th1-sumw2-correspond-to/39463/2 "2020-05-18T07:15:25Z")

</div>

Hi,  
For the statistics of weighted events, one of the best statistical description is provided by this paper,

> **[1309.1287.pdf](https://arxiv.org/pdf/1309.1287.pdf)**
>
> 191.69 KB

Lorenzo

---

<div class="post-metadata">

**Author:** ![eggsAndCoffee](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/ecb155/32.png) [@eggsAndCoffee](https://root-forum.cern.ch/u/eggsAndCoffee)\
**Post date:** [May 18, 2020, 3:44pm UTC](https://root-forum.cern.ch/t/what-distribution-does-th1-sumw2-correspond-to/39463/3 "2020-05-18T15:44:16Z")

</div>

Thank you Lorenzo. That was a good paper, and it helps my understanding. It’s still not totally clear to me why the uncertainties might be calculated as the sqrt(sum of weight^2) though, and as far as I can tell the paper does not specifically address that does it? Equations 2 and 7 in the paper are pretty similar to the form that I might expect for Sumw2 error calculation, but I can’t make the connection.

Let me get this straight, then. Are you saying that for weighted Poisson events, the error is calcualted as sqrt(sum of weight^2), and that somewhere in the paper you’ve provided this result is proven and that I’ve just missed it?

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [May 19, 2020, 9:04am UTC](https://root-forum.cern.ch/t/what-distribution-does-th1-sumw2-correspond-to/39463/4 "2020-05-19T09:04:40Z")

</div>

Hi,

You can use simply the rules of expectation values to come out to the conclusion that the uncertainty can be estimated as sqrt(sum of weight^2).  
Equation (7) in the paper shows well this. A bin filled with weighted entries can be seen as described by a compound Poisson distribution, sum of N random variable, where N is Poisson distributed with expected value lambda.  
You can find more info also in [https://en.wikipedia.org/wiki/Compound\_Poisson\_distribution](https://en.wikipedia.org/wiki/Compound_Poisson_distribution) where  
you have a formula and proof for the variance (and then the uncertainty).  
In the case that the expected number of events in the bin is assumed to be equal to the observed one, then E(N) =N (e.g in case of Neyman chi-square) , i.e. lambda ~= N

I hope this helps your understanding

Lorenzo

---

<div class="post-metadata">

**Author:** ![eggsAndCoffee](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/ecb155/32.png) [@eggsAndCoffee](https://root-forum.cern.ch/u/eggsAndCoffee)\
**Post date:** [May 19, 2020, 11:35am UTC](https://root-forum.cern.ch/t/what-distribution-does-th1-sumw2-correspond-to/39463/5 "2020-05-19T11:35:28Z")

</div>

Ok yes, I get it now! Thank you very much, very helpful.
