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

**URL:** <https://root-forum.cern.ch/t/tmath-median-his-getquantiles-1-0-5-x/29979>\
**Category:** ROOT\
**Tags:** math\
**Created:** [July 26, 2018, 1:34pm UTC](https://root-forum.cern.ch/t/tmath-median-his-getquantiles-1-0-5-x/29979 "2018-07-26T13:34:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bdrum](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bdrum/32/16729_2.png) [@bdrum](https://root-forum.cern.ch/u/bdrum)\
**Post date:** [July 26, 2018, 1:34pm UTC](https://root-forum.cern.ch/t/tmath-median-his-getquantiles-1-0-5-x/29979/1 "2018-07-26T13:34:10Z")

</div>

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?

```auto
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

* * *

---

<div class="post-metadata">

**Author:** ![bdrum](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bdrum/32/16729_2.png) [@bdrum](https://root-forum.cern.ch/u/bdrum)\
**Post date:** [July 26, 2018, 1:46pm UTC](https://root-forum.cern.ch/t/tmath-median-his-getquantiles-1-0-5-x/29979/2 "2018-07-26T13:46:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [August 9, 2018, 1:46pm UTC](https://root-forum.cern.ch/t/tmath-median-his-getquantiles-1-0-5-x/29979/3 "2018-08-09T13:46:24Z")

</div>

Closed on August 9, 2018, 1:46pm UTC

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