# TEfficiency output versus posterior distribution

**URL:** <https://root-forum.cern.ch/t/tefficiency-output-versus-posterior-distribution/34643>\
**Category:** Newbie\
**Created:** [June 17, 2019, 10:08am UTC](https://root-forum.cern.ch/t/tefficiency-output-versus-posterior-distribution/34643 "2019-06-17T10:08:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cvergis](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/c/bbce88/32.png) [@cvergis](https://root-forum.cern.ch/u/cvergis)\
**Post date:** [June 17, 2019, 10:08am UTC](https://root-forum.cern.ch/t/tefficiency-output-versus-posterior-distribution/34643/1 "2019-06-17T10:08:09Z")

</div>

Hi all,

I have a question about the TEfficiency class. I am trying to calculate the error given by the division of two efficiencies (data and simulation) and for that I will try to generate random numbers using the posterior pdf of the efficiencies. If I understood correctly the documentation of TEfficiency, when using a uniform prior the posterior is still a Beta distribution with modified a,b parameters: a’=a+k, b’=a+n-k.

The following code shows the efficiency calculation in one bin. The efficiency returned is: 0.0176604693439. However, the function’s integral tells me that the mode is in a higher position (around 0.0183 as shown in the plot). Do you know what might be the cause of this?

 ![roothelp](https://root-forum.cern.ch/uploads/default/original/3X/f/0/f0cb15d23aaa7e7f9850e47d37a40492e1298573.png)

Thanks,  
Christos Vergis

```auto
    if(ROOT.TEfficiency.CheckConsistency(hpas2,htot2)):
        ef = ROOT.TEfficiency(hpas2, htot2)
        ef.SetPosteriorMode()
        ef.SetStatisticOption(ROOT.TEfficiency.kBUniform)

        n = htot2.GetBinContent(5) #969.47479248 
        k = hpas2.GetBinContent(5) #17.1213798523
        apr = ef.GetBetaAlpha(5)+k
        bpr = ef.GetBetaBeta(5)+n-k
        fun = ROOT.TF1("fun","TMath::BetaDist(x,%s,%s)"%(apr,bpr),0,1)
        fun.SetNpx(10000)

        fun.DrawIntegral()
        print ef.GetEfficiency(5),ef.GetEfficiencyErrorLow(5),ef.GetEfficiencyErrorUp(5)

```

---

<div class="post-metadata">

**Author:** ![cvergis](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/c/bbce88/32.png) [@cvergis](https://root-forum.cern.ch/u/cvergis)\
**Post date:** [June 17, 2019, 7:19pm UTC](https://root-forum.cern.ch/t/tefficiency-output-versus-posterior-distribution/34643/2 "2019-06-17T19:19:53Z")

</div>

Hi,  
Sorry I managed to understand my misconception, being that the mode would be the same as the median. Since that is not true, everything is clear.

Thanks.
