# Quantile of a TH1 using GetQuantiles()

**URL:** <https://root-forum.cern.ch/t/quantile-of-a-th1-using-getquantiles/39954>\
**Category:** Newbie\
**Created:** [June 17, 2020, 6:29pm UTC](https://root-forum.cern.ch/t/quantile-of-a-th1-using-getquantiles/39954 "2020-06-17T18:29:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Newbie](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/dc4da7/32.png) [@Newbie](https://root-forum.cern.ch/u/Newbie)\
**Post date:** [June 17, 2020, 6:29pm UTC](https://root-forum.cern.ch/t/quantile-of-a-th1-using-getquantiles/39954/1 "2020-06-17T18:29:33Z")

</div>

Dear,

I’m trying to get the quantile value for 60%, and here is what I’m doing

> h = ROOT.TH1F(“h”,“demo quantiles”,100,-3,3)  
> h.FillRandom(“gaus”,5000)  
> prob=np.array([0.6])  
> q=np.array([0.])  
> print h.GetQuantiles(1,q,prob)

But this is returning 1, regardless of what my histogram is, am I doing something wrong?

many thanks!

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [June 17, 2020, 6:39pm UTC](https://root-forum.cern.ch/t/quantile-of-a-th1-using-getquantiles/39954/2 "2020-06-17T18:39:15Z")

</div>

[TH1::GetQuantiles](https://root.cern/doc/master/classTH1.html#a2be4a5889f7421047d68b0a398675b8d)

---

<div class="post-metadata">

**Author:** ![Newbie](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/dc4da7/32.png) [@Newbie](https://root-forum.cern.ch/u/Newbie)\
**Post date:** [June 22, 2020, 11:02pm UTC](https://root-forum.cern.ch/t/quantile-of-a-th1-using-getquantiles/39954/3 "2020-06-22T23:02:47Z")

</div>

Hi! I based my example on it, but I still don’t know how to compute a single value.

My example is not working, is there anything wrong there?

Thanks

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [June 23, 2020, 5:04am UTC](https://root-forum.cern.ch/t/quantile-of-a-th1-using-getquantiles/39954/4 "2020-06-23T05:04:17Z")

</div>

The documentation Wile linked says that the return value of GetQuantiles is a single integer, `the number of quantiles computed`. In your example you want to print q (and maybe prob).

---

<div class="post-metadata">

**Author:** ![Newbie](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/dc4da7/32.png) [@Newbie](https://root-forum.cern.ch/u/Newbie)\
**Post date:** [June 23, 2020, 11:14am UTC](https://root-forum.cern.ch/t/quantile-of-a-th1-using-getquantiles/39954/5 "2020-06-23T11:14:31Z")

</div>

Thanks a lot! I thought that the function gives the quantile(s), but now it’s clear!
