# Subtracting histograms does not yield difference in entries

**URL:** <https://root-forum.cern.ch/t/subtracting-histograms-does-not-yield-difference-in-entries/31133>\
**Category:** ROOT\
**Tags:** bug, hist\
**Created:** [October 16, 2018, 3:55pm UTC](https://root-forum.cern.ch/t/subtracting-histograms-does-not-yield-difference-in-entries/31133 "2018-10-16T15:55:43Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [October 16, 2018, 4:01pm UTC](https://root-forum.cern.ch/t/subtracting-histograms-does-not-yield-difference-in-entries/31133/2 "2018-10-16T16:01:05Z")

</div>

> [@Subtracting multiple histogram with same TH2F](https://root-forum.cern.ch/t/subtracting-multiple-histogram-with-same-th2f/31114/2):
>
> I guess you could be interested in the [TH1:Integral](https://root.cern.ch/root/html534/TH1.html#TH1:Integral@1) / [TH2::Integral](https://root.cern.ch/root/html534/TH2.html#TH2:Integral@1) / [TH3::Integral](https://root.cern.ch/root/html534/TH3.html#TH3:Integral@1) and / or the [TH1::IntegralAndError](https://root.cern.ch/root/html534/TH1.html#TH1:IntegralAndError) / [TH2::IntegralAndError](https://root.cern.ch/root/html534/TH2.html#TH2:IntegralAndError) / [TH3::IntegralAndError](https://root.cern.ch/root/html534/TH3.html#TH3:IntegralAndError) methods. When you “subtract” histograms, the “number of entries” is recalculated in a different way than when you “add” them so, you may get “unexpected” / “weird” values. { TH1F \*h1 = new TH1F("h1", "h1", 100, -5., 5.); h1-\>Sumw2(kTRUE); #if 0 /\* 0 or 1 \*/ h1-\>FillRandom("gaus"); #else /\* 0 or 1 \*/ for (Int\_t i = 0; i \< …

---

_[View the full topic](https://root-forum.cern.ch/t/subtracting-histograms-does-not-yield-difference-in-entries/31133)._
