# How the error of the standard distribution is calculated in root?

**URL:** <https://root-forum.cern.ch/t/how-the-error-of-the-standard-distribution-is-calculated-in-root/51411>\
**Category:** Newbie\
**Tags:** hist\
**Created:** [August 31, 2022, 10:11am UTC](https://root-forum.cern.ch/t/how-the-error-of-the-standard-distribution-is-calculated-in-root/51411 "2022-08-31T10:11:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gini](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/gini/32/29467_2.png) [@gini](https://root-forum.cern.ch/u/gini)\
**Post date:** [August 31, 2022, 10:11am UTC](https://root-forum.cern.ch/t/how-the-error-of-the-standard-distribution-is-calculated-in-root/51411/1 "2022-08-31T10:11:22Z")

</div>

Hi,

I wonder how the errors of the standard deviation of a histogram are calculated in root?

Say for example, in the following histogram (TH1D\*h1 = new TH1D(“h1”,“Au\_158.62\_MeV”,101.,39.5,140.5) attached :

 ![std](https://root-forum.cern.ch/uploads/default/original/3X/2/8/282ff4084dd04f146a46147e6d3df18791e08b06.png)

Here the estimation of the mean, error in the mean and the standard deviation are straightforward using the following equation :

![eqn](https://root-forum.cern.ch/uploads/default/original/3X/0/7/077f6e0027485287c68adfd6970e8ca45d283ca0.png)

But I don’t understand how the error in the standard deviation is calculated by root. Any help appreciated. Thank you.

---

<div class="post-metadata">

**Author:** ![jonas](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jonas/32/24756_2.png) [@jonas](https://root-forum.cern.ch/u/jonas)\
**Post date:** [August 31, 2022, 12:11pm UTC](https://root-forum.cern.ch/t/how-the-error-of-the-standard-distribution-is-calculated-in-root/51411/2 "2022-08-31T12:11:19Z")

</div>

Hi! Thanks for the question.

the uncertainty for the standard deviation is calculated as \sqrt{\frac{\sigma^2}{2n}}, which is the right estimator if the underlying distribution is Gaussian. For a general distribution this is not exact, because the right formula requires the 4th momentum of the distribution, which is not available to the histogram because of the binning.

I got this information from the source code:

> <https://github.com/root-project/root/blob/master/hist/hist/src/TH1.cxx#L7536>

This should probably also be written in the docs, so thanks for the reminder!

---

<div class="post-metadata">

**Author:** ![Dilicus](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dilicus/32/14338_2.png) [@Dilicus](https://root-forum.cern.ch/u/Dilicus)\
**Post date:** [August 31, 2022, 12:20pm UTC](https://root-forum.cern.ch/t/how-the-error-of-the-standard-distribution-is-calculated-in-root/51411/3 "2022-08-31T12:20:20Z")

</div>

The variance error is given by

![image](https://root-forum.cern.ch/uploads/default/original/3X/e/d/ed519e98edddb1b95ce118fe0dd1f38eb5101c22.png)

So to have the error on the square root of the variance you just need to evaluate  
 ![image](https://root-forum.cern.ch/uploads/default/original/3X/2/c/2c965fd4adfe0dfbba5bcce6e7c791f1db6fce02.png)

Edit:  
But as said by jonas this formula is valid only for gaussian.

---

<div class="post-metadata">

**Author:** ![gini](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/gini/32/29467_2.png) [@gini](https://root-forum.cern.ch/u/gini)\
**Post date:** [August 31, 2022, 12:39pm UTC](https://root-forum.cern.ch/t/how-the-error-of-the-standard-distribution-is-calculated-in-root/51411/4 "2022-08-31T12:39:37Z")

</div>

Thank you @jonas and @Dilicus for the clarification.
