Random Number Generator

Hi all,

I have a distribution with a certain x-range (3 to 9) splitted in two bins. The first bin(3 to 4) contains the 80% of my events and the second one (4 to 9) contains the remaining 20%. I need to generate random numbers in each bin but with a sequence of 80% probability getting numbers from the first bin (from 3 to 4) and 20% probability to get random numbers within the second bin(from 4 to 9). More simply, imagine tossing a coin and having 80% probability for tails and 20% for heads. Is there any function in root where I can do that? I would guess TRandom with binomial option !? If so, would it be possible to define a range for the generation of the numbers according to the range of my bins or just the mean of each of the above bins would be enough?

I know that my question is a bit general but I would appreciate any help.

Thank you in advance,
Steve

Hi Steve,

this method provides the functionality you are looking for: root.cern.ch/doc/master/classTH … 46e7d192cc

Cheers,
D