Home | News | Documentation | Download

Can one pass dPDF to ROOT::Math::DistSampler for Unuran?


Looking both at the 6.22 and master I cannot see any way to pass the PDF derivative or CDF to the DistSampler to be used by the Unuran implementation. Did I miss something?

Furthermore, do I understand correctly that to change parameters of Unuran for the given method/algorithm, one has to add appropriate string options to the algorithm passed to DistSampler::Init()? I don’t see this documented, but looks like TUnuran (not TUnuranSampler) parses the argument into the parameters.


May be @moneta can help.

At the moment this is not supported for the ROOT::Math::DistSampler class. It could be an easy extension to add if needed.
If you need to pass the PDF derivative or CDF, you should use directly the lower level class, TUnuranContDist. See the class documentation (ROOT: TUnuranContDist Class Reference) and the tutorial ROOT: tutorials/unuran/unuranDemo.C File Reference.

It is correct, for changing parameter of distribution, you would need to call Init again, since for every distribution defending on the parameters, some setting up time is needed.
How long it takes to setup it will depend on the chosen algorithm. Some are very fast for sampling but requires larger setup time.
If you have further questions, please let me know




Thanks. Regarding the derivate and CDF, it looks like a reasonable thing to add for completeness. There already is SetMode which is ignored by Foam, so it it there exclusively for Unuran and it is used by only few of its algorithms/methods. Why not to add the other 2 things that some Unuran algorithms require? It seems rather awkward to be forced to move to the lower level just to use a chosen algorithm for the same class of problems.

I didn’t mean re-init of Unuran. The point is that each Unuran method has some tuning parameters. I am asking if it is possible to set them by including them in the string passed to DistSampler::Init()? If so, it should probably be documented both in TUnuran and in TUnuranSampler (possibly by reference to the former).


I agree and I’ll add in the things to do fo Unuran. I’ll open a GitHub issue for this.

for passing UNURAN tuning parameters, I think the only current way is using the string API of UNURAN, for example for the tdr method, pass a string as :

TUnuran unr;
std::string distr = "distr = cont; pdf=\"1-x*x\"; domain=(-1,1); mode=0.distr = cont; pdf=\"1-x*x\"; domain=(-1,1); mode=0.";
std::string method = "method=tdr; variant_gw; max_sqhratio=0.90; c=-0.5; max_intervals=100; cpoints=10";

See the UNURAN doc for this (UNU.RAN User Manual)
Another possible extensions is to add support when providing also function objects.


Hi Lorenzo,
Thanks, this finalizes it.