Re: TRandom methods

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue Jan 18 2000 - 12:42:16 MET


Alexander,
The move to OO is given new possibilities for random number generation.
In particular, the possibility to have more than one object
with different seeds sequence is extremely important.
This was badly missing when we were working with Fortran based
random number generators.
Having static functions in the random number generator classes
is a STEP BACKWARD !

Second point. the Root random number generator classes exploit
inheritance
and virtual functions for all the functions you list below.
This is exploited by the classes TRandom2 and TRandom3.

Concerning the return type, all functions return double except Rndm.
I could change this type to double (or add a new function).
In fact, TRandom2::Rndm and TRandom3::Rndm already compute a double.

Rene Brun

ZVYAGIN wrote:
> 
> Dear ROOTers,
> 
> I have a couple of questions about methods of TRandom class.
> 
> These are declarations from class TRandom
> 
> virtual Float_t Gaus      (Float_t mean = 0, Float_t sigma = 1)
> virtual Float_t Landau    (Float_t mean = 0, Float_t sigma = 1)
> virtual Int_t   Poisson   (Float_t mean)
> virtual void    Rannor    (Float_t& a, Float_t& b)
> virtual Float_t Rndm      (Int_t i = 0)
> 
> The first question: why all this methods are not 'static' ones? It will be
> much simpler to use code
> 
> double r = TRandom::Gaus();  // Very simple and clear. Like in CLHEP
> 
> then
> 
> TRandom rndm;
> double r = rndm.Gaus();
> 
> May be it is better to have static function (like in class TMath) plus
> method for setting user-defined engine of random generator instead of
> single virtual function?
> 
> The second question. Are there any problems that prevents using Double_t
> type instead of Float_t? The code I have requires double type and can not
> work with Float_t. (That is why I use CLHEP instead of ROOT for
> generating random numbers.)
> 
> P.S. The keyword 'static' is not present on generated HTML documentation.
> Take a look on http://root.cern.ch/root/html/TMath.html (you will not
> find 'static' keyword) and then on $ROOTSYS/TMath.h.
> 
> With best wishes,
> Alexander.



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:17 MET