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.
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