How to use ROOT::Math::DistSampler?

I have to do sampling from a few distributions like NBD and Gamma distribution. I tried declaring the pdf as a TF1 function and then obtained the samples by TF1::GetRandom() method. Then I plotted TH1D for the generated samples(~1E7 samples).
The problem is that I never get back the mean and variance, that I put into the pdf, in the TH1D that I plot. The mean is always larger.

Then I also tried acceptance and rejection method. And got the same results.
So now I wanted to try using DistSampler Class of ROOT. But I do not know how to use it.


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Maybe @moneta can give more details, but did you check the multidimSampling.C tutorial?

HI,

You can look also at the program:
https://root.cern.ch/doc/v606/testDistSampler_8cxx_source.html#l00018

and at the reference documentation

https://root.cern.ch/doc/v606/classROOT_1_1Math_1_1DistSampler.html#a77219bfeb75360d2a5c86e1b8dc04fa2

It is mainly an abstract class which is re-implemented for example by the sampler based on unuran, which provide several sampling algorithms (class TUnuranSampler)
You can see then for the list of anuran algorithms in the anuran documentation,
http://statmath.wu-wien.ac.at/unuran/doc/unuran.html#AUTO

If you have more questions, please let us know
Best regards
Lorenzo

Thank you for prompt replies. I’ll look into these soon.

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