Rms90

Hi,

is there a tool to easly calculate the RMS of central 90% of the entries in a histogram?

Thank you

           Anna

It depends how you define the central 90% (model dependent).
Below a brute force example.

Rene

[code]void rms90(TH1 h) {
TAxis axis = h->GetXaxis();
Int_t nbins = axis->GetNbins();
Int_t imean = axis->FindBin(h->GetMean());
Double_t entries =0.9
h->GetEntries();
Double_t w = h->GetBinContent(imean);
Double_t x = h->GetBinCenter(imean);
Double_t sumw = w;
Double_t sumwx = w
x;
Double_t sumwx2 = wxx;
for (Int_t i=1;i<nbins;i++) {
if (i> 0) {
w = h->GetBinContent(imean-i);
x = h->GetBinCenter(imean-i);
sumw += w;
sumwx += wx;
sumwx2 += w
xx;
}
if (i<= nbins) {
w = h->GetBinContent(imean+i);
x = h->GetBinCenter(imean+i);
sumw += w;
sumwx += w
x;
sumwx2 += wxx;
}
if (sumw > entries) break;
}
x = sumwx/sumw;
Double_t rms2 = TMath::Abs(sumwx2/sumw -x*x);
Double_t result = TMath::Sqrt(rms2);
printf(“RMS of central 90% = %g, RMS total = %g\n”,result,h->GetRMS());
}

void central90() {
TH1F *h = new TH1F(“h”,“test”,100,-4,2);
h->FillRandom(“gaus”,10000);
rms90(h);
}[/code]