Could I play toyMC sampling on a histogram?

Is it that I could only play toyMC with a defined PDF? I wonder if I only have a histogram without any known PDF, whether could I sample according to the shape of the histogram? If so, could anyone be kind to tell me the codes, please? Thanks so much!


Conceptually this is always possible as long as the histogram has no negative entries.
Do you want to know how to do this in plain ROOT or in RooFit?


Yes, could you tell me? Thanks so much.

use TH1::GetRandom, TH2::GetRandom, etc


1 Like