Sample from pdf previously defined in RooStats

Hi all,

suppose that you have defined a model in RooStats, with some arbitrary pdf.
Then you want to fill a vector of random numbers, sampled from one of those pdf.
Is there an easy way to do that? (I guess starting from wspace->pdf(“nameOfPdf”)…).

Thank you.



You can use RooAbsPdf::generate to get a data set containing containing a vector of observables values from a random sampling of the pdf



Thank you,

in fact I tried in that way but I got always a flat spectrum… I have solved the problem in a different way (I created an identical roofit object with the same expression and the same parameters). It’s not an elegant solution, but it was just made for debugging purposes, and it could be fine.

Thanks a lot for the hint!