Re: Random Numbers revisited.

Rene Brun (Rene.Brun@cern.ch)
Fri, 31 Jul 1998 14:06:13 +0200


Pasha Murat wrote:
>
>
> Hello,
> I feel that I am missing something in the discussion above so I'd
> appreciate to be given a clarification. Let me explain what exactly I'm
> missing:
>
> - what `hrndm1' does it returns a *single* random number distributed
> according a probability distribution stored in a given histogram.
> - `FillRandom' methods do very different thing - they *fill a histogram*
> according to a given probability density stored elsewhere, therefore it seems
> to me that they miss functionality of `hrndm1' which is quite often needed by
> the users.
>
> So is it possible to generate (and retrieve!) a single random number (set of
> numbers) which probability density is stored in a given histogram ?
>

Currently the following functions are provided
-TF1::GetRandom returns one number at the time from a theoretical
function.Note that TF1::GetRandom uses the real integral of
the function and not just the sum of the function precomputed
for some bins as it was the case in Hbook for example.

-TH1::FillRandom(TF1 *) generates a bunch of random numbers
from a theoretical function (1-d,2-d,3-d) and fill an histogram
-TH1::FillRandom(TH1 *) generates a bunch of random numbers
from a histogram (1-d,2-d or 3-d) and fill a histogram.

I could provide a TH1::GetRandom or similar for 2-d and 3-d.
To do that, I must store the integral of the bin contents somewhere
as it is out of question to recompute this integral at every call
like in TH1::FillRandom. I will add this item to my list.

Rene Brun