Hello,

I have been working on the plot of a histogram. I use the Scale method to normalize the graph so that the y-coordinate behaves as the probability density instead of frequency. However, when I draw the error bar of this graph by using Draw->(“E1”), the error bar becomes so big. Is there a way I can normalize the error bar as well?

Thanks a lot!!!

Hello,

@moneta can help you with this question but it would be very helpful is you can send a small macro reproducing the problem you encounter.

Hi,

To scale an histogram to be as a probability density (i.e. that the integral = 1), you need to do : ’

```
hist->Scale(1./hist->Integral(),"width");
```

The error should be calculated correctly if you are using one of the latest version. In older versions you might need too do before calling Scale,

```
hist->Sumw2();
```

Best Regards

Lorenzo

Thanks, here is a sample of the macro i write:

Double_t norm = 1;

Double_t scale = norm/(simu->Integral());

simu->Scale(scale);

simu->Draw(“E1”);

Hello,

thanks for your help. I add the “width” option in the Scale function as you suggest. Comparing to the original graph, the error bar seems to grow a little narrower but doesn’t change that much. Are there any other methods that I can use to decrease the size of the error bar?

Hi,

You can scale the histogram with the constant you want, but if you want an histogram representing a probability density, i.e. that the bin content * bin width = probability of observing an event in a bin, then the way to do is the one I have written before.

The bin errors are computed correctly, assuming the normal approximation. You can always set to the value you want using SetBinError, but you need to be sure what you are doing

Lorenzo

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