Hey! I’m new here, so pardon me if this is a relatively stupid question.

Basically I have been trying to use ToyMCSampler in conjunction with ProfileLikelihoodTestStat to try and generate sampling distributions for my test statistic (the ultimate aim being to try and compare the results with Wilk’s theorem and the asymptotic approximation).

I was a little unclear about how and where exactly in the ToyMCSampler.cxx code (link here : https://root.cern/doc/master/ToyMCSampler_8cxx_source.html ) the nuisance parameters from my workspace are being randomised (while the toy data is being generated of course).

In line 631 you finally see the pdf.generate() command; does that automatically somehow randomise the nuisance parameters (other than the parameter of interest of course) while generating the data? As far as I know, for each generated dataset, the nominal values (or Global Observables) are set to values gotten from the workspace, while the nuisance parameters are randomised. So where exactly does this happen in the code? More importantly how does it happen? As in, does it take into account the constraint terms for these nuisance parameters that I’ve defined in my workspace?

This could be a stupid question, but I would appreciate any pointers/help.

Thanks in advance!