# Error for mean from histogram

**URL:** <https://root-forum.cern.ch/t/error-for-mean-from-histogram/53216>\
**Category:** Newbie\
**Created:** [January 23, 2023, 9:57am UTC](https://root-forum.cern.ch/t/error-for-mean-from-histogram/53216 "2023-01-23T09:57:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Progressive](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/dfb087/32.png) [@Progressive](https://root-forum.cern.ch/u/Progressive)\
**Post date:** [January 23, 2023, 9:57am UTC](https://root-forum.cern.ch/t/error-for-mean-from-histogram/53216/1 "2023-01-23T09:57:47Z")

</div>

* * *

_ROOT Version:_ 6.26/02  
_Platform:_ Windows  
_Compiler:_ MSVC 19.31.31104.0

* * *

Hi,

I’ve seen on [https://root.cern.ch/root/htmldoc/guides/users-guide/Histograms.html`](https://root.cern.ch/root/htmldoc/guides/users-guide/Histograms.html%60) When a histogram has errors, it is visualized by default with error bars.` what does this mean? Do I have to add errors manually e.g. when writing a tree? What is the difference to use the statistics box?

Thank you!

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [January 23, 2023, 10:24am UTC](https://root-forum.cern.ch/t/error-for-mean-from-histogram/53216/2 "2023-01-23T10:24:28Z")

</div>

When a 1D histogram has some errors built into its data structure and you do:

```auto
hist->Draw();

```

Then the error bars are drawn. If you do not want to see the errors bars for a such histogram  
you need to do:

```auto
hist->Draw("HIST");

```

When a 1D histogram has NO errors built into its data structure and you do:

```auto
hist->Draw();

```

Then the error bars NOT drawn. If you want to see some errors bars automatically computed for a such histogram you need to do:

```auto
hist->Draw("E");

```

---

<div class="post-metadata">

**Author:** ![Progressive](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/dfb087/32.png) [@Progressive](https://root-forum.cern.ch/u/Progressive)\
**Post date:** [January 23, 2023, 12:06pm UTC](https://root-forum.cern.ch/t/error-for-mean-from-histogram/53216/3 "2023-01-23T12:06:59Z")

</div>

Thank you! Are the errors the same in both cases?

I assume in the first case they are individually computed while the second case use kind of a standard procedure or formula?

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [January 23, 2023, 12:34pm UTC](https://root-forum.cern.ch/t/error-for-mean-from-histogram/53216/4 "2023-01-23T12:34:03Z")

</div>

See: [ROOT: TH1 Class Reference](https://root.cern/doc/master/classTH1.html#aefa4ee94f053ec3d217f3223b01fa014) (Sumw2)  
or [ROOT: TH1 Class Reference](https://root.cern/doc/master/classTH1.html#a02b9ba99fdb9312861ac3a0f5d25946d) (SetErrors)

---

<div class="post-metadata">

**Author:** ![Progressive](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/dfb087/32.png) [@Progressive](https://root-forum.cern.ch/u/Progressive)\
**Post date:** [January 27, 2023, 8:12am UTC](https://root-forum.cern.ch/t/error-for-mean-from-histogram/53216/5 "2023-01-27T08:12:33Z")

</div>

Thank you, again!

Is it possible to display e.g the mean error as a percentage of the mean instead of a raw value? Guess it would be a relative error then(?).  
Btw, I’m using `gStyle->SetOptStat("eMR");` which can be found under `5.8.5 Statistics Display` on [Chapter: Histograms](https://root.cern.ch/root/htmldoc/guides/users-guide/Histograms.html)

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [January 27, 2023, 8:55am UTC](https://root-forum.cern.ch/t/error-for-mean-from-histogram/53216/6 "2023-01-27T08:55:34Z")

</div>

> [@Progressive](#):
>
> the mean error as a percentage of the mean instead of a raw value

No, there is no option for that, you will need to compute it and display it yourself.
