# Mean and MeanError of a variable bin size TH1

Dear ROOT users,

I’ve an histogram with a variable bin size (given by detector time resolution) and I would like to compute the mean (the equivalent for GetMean()) and the uncertainty on the mean (the equivalent for GetMeanError()).
I’m wondering if there is a way to tell ROOT about the variable bin size, because, as far as I could see, it is not accounted for in the GetMean() and GetMeanError() methods.

Cheers
Paola

Well, the “precision” of results is somehow limited by bins’ widths …

``````{
#if 0 /* 0 or 1 */
TH1D *h = new TH1D("h", "h", 200, -10., 10.);
#else /* 0 or 1 */
Double_t x[] = {-10., -6., -3., -1., 0., 5., 10.};
Int_t n = sizeof(x) / sizeof(Double_t) - 1;
TH1D *h = new TH1D("h", "h", n, x);
#endif /* 0 or 1 */
// h->Sumw2(kTRUE);
h->FillRandom("gaus", 1000000);
// h->Scale(1.0, "width");
// h->Sumw2(kFALSE);
h->Draw(); // note: it should be ... Mean = 0.0, RMS = Std Dev = 1.0
std::cout << h->GetMean() << " : " << h->GetMeanError() << std::endl;
}
``````

Hi Wile,
Maybe you want to play with (see my previous post again): `h->Scale(1.0, "width");`