TMath::Median() != his->GetQuantiles(1,0.5,x)

Hello Rooters!

Hmmm, I’m not sure in category, sorry if I chose the wrong one.

Can you help me please with some statistical stuff:
I would like to get some stats units from my histogram (TH1D), but I noticed a strange thing:
0.5 quantile not equal to median. But it should be!?

So, please, tell me what wrong in my code?

root [] TH1D *his = new TH1D("his", "his", 100, -4,4);
root [] his->FillRandom("gaus")
 root [] TMath::Median(his->GetSize(), his->GetArray())
(double) 22.000000
root []  Double_t x,q;
root [] q = 0.5
(double) 0.50000000
root []  his->GetQuantiles(1,&x,&q);
root [] x
(double) 0.0023357664

_ROOT Version:_6.15
Platform: ubuntu 18.04
Compiler: gcc 7.3.0

The problem is:
his->GetArray() returns y-values, so in my case I got median from y-values, but his->GetQuantiles work with x-values.

1 Like

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