Re: Random Numbers revisited.

Rene Brun (Rene.Brun@cern.ch)
Tue, 28 Jul 1998 19:19:05 +0200


millerte wrote:
>
> Hi Rene,
>
> First of all, I apologize for sending this directly to you instead
> of the list. I am abroad and had to suspend my receiving the list
> until I returned (nasty email quotas).
>
> Anyhow, I am aware of several methods to generate random numbers...
> however, the one that is missing (translate, I can't find) is the
> generation from a histogram. Now, if there is a nice distribution
> in the histogram, one can fit it to a function and generate numbers
> using the TF1->GetRandom() functionality. However, when the
> histogram is not smooth (in my case, antiproton production per
> event...lots of zeros and a few ones at AGS energies), this method
> breaks down.
>
> In PAW, the corresponding function call was 'hrndm1'. Perhaps one
> of several solutions exist currently: that functionality is there
> and I'm blind at reading the class def, a "good" function to fit
> to my current histogram exists but I'm not clever enough to figure
> it out, or perhaps this functionality is "in the pipeline"?
>
> Thanks for your time,
> -Tim

Tim,
This method exists in ROOT.
TH1 class has 2 methods FillRandom
void FillRandom(char *fname, Int_t ntimes=5000);
void FillRandom(TH1 *h, Int_t ntimes=5000);

The 1st starts from a function, the 2nd one from an histogram.

Rene Brun