I’m having trouble understanding the output of GetQuantiles().
I am using the following code:
void quantiles() {
// demo for quantiles
const Int_t nq = 3;
TH1F *h = new TH1F("h","demo quantiles",100,-3,3);
h->FillRandom("gaus",5000);
Double_t xq[nq]; // position where to compute the quantiles in [0,1]
Double_t yq[nq]; // array to contain the quantiles
for (Int_t i=0;i<nq;i++) xq[i] = Float_t(i+1)/nq;
h->GetQuantiles(nq,yq,xq);
//show the original histogram in the top pad
TCanvas *c1 = new TCanvas("c1","demo quantiles",10,10,700,900);
c1->Divide(1,2);
c1->cd(1);
h->Draw();
// show the quantiles in the bottom pad
c1->cd(2);
gPad->SetGrid();
TGraph *gr = new TGraph(nq,xq,yq);
gr->SetMarkerStyle(21);
gr->Draw("alp");
}
taken from the GetQuantiles() entry of TH1 Class Reference.
I have set nq=3 because I am interested in calculating the Interquartile Range (IQR - https://en.wikipedia.org/wiki/Interquartile_range) so I can do Freedman-Diaconis binning – I’d put in the wikipedia link, but as a new user, I’m evidently limited to 2 link >:-| – on my histograms which have >5x10^6 entries.
When I run quantiles(), I get the following plot:
quantile.pdf (15.2 KB)
and I don’t know how to interpret the bottom plot.
What I need is the IQR of a set of values, i.e. the difference between the median of the upper half of the values and the median of the lower half of the values.
Maybe Quantiles() is the wrong function to use for getting these numbers, and maybe there is no ROOT function to get these numbers, and I’ll have to write the code to do so by hand.
But if there is a easy ROOT method to get these numbers, I’d rather have ROOT do the work for me.
Thanks for your help,
James N