Relacs Numerics Library  0.9.8
Public Member Functions | List of all members
RandomBase Class Referenceabstract

#include <random.h>

Inheritance diagram for RandomBase:
Inheritance graph
[legend]

Public Member Functions

 RandomBase (void)
 
 RandomBase (unsigned long seed)
 
virtual ~RandomBase (void)
 
virtual unsigned long setSeed (unsigned long seed)=0
 
virtual unsigned long integer (void)=0
 
virtual unsigned long min (void) const =0
 
virtual unsigned long max (void) const =0
 
unsigned long operator() (unsigned long n)
 
double operator() (void)
 
virtual double uniform (void)=0
 
virtual double gaussian (void)=0
 
virtual double exponential (void)
 
virtual double gamma (int a)
 
virtual string name (void)=0
 

Detailed Description

The base class for random number generators.

Author
Jan Benda
Version
1.0 A global variable rnd is defined with the best available random generator available on your system.
double v = rnd(); // a random number from the uniform distribution [0,1)
double g = rnd.gaussian(); // a random number from a gaussian distribution.

Constructor & Destructor Documentation

RandomBase ( void  )
inline
RandomBase ( unsigned long  seed)
inline
virtual ~RandomBase ( void  )
inlinevirtual

Member Function Documentation

virtual unsigned long setSeed ( unsigned long  seed)
pure virtual

Set the seed of the random number generator to seed. If seed is 0, then the system time is used to generate a seed to imitate real randomness. Returns the seed.

Implemented in RandomGSL, Ran3, and RandomStd.

virtual unsigned long integer ( void  )
pure virtual

Returns a uniformly distributed random integer between min() and max().

Implemented in RandomGSL, Ran3, and RandomStd.

virtual unsigned long min ( void  ) const
pure virtual

The minimum value integer() returns.

Implemented in RandomGSL, Ran3, and RandomStd.

virtual unsigned long max ( void  ) const
pure virtual

The maximum value integer() returns.

Implemented in RandomGSL, Ran3, and RandomStd.

unsigned long operator() ( unsigned long  n)

Returns an uniformly distributed integer random number between zero and n. The range includes 0 but excludes n. This operator conforms to the STL RandomNumberGenerator specification. This function is NOT virtual in order to speed up computation.

double operator() ( void  )

Returns an uniformly distributed random number between zero and one. The range includes 0.0 but excludes 1.0.

virtual double uniform ( void  )
pure virtual

Returns an uniformly distributed random number between zero and one. The range includes 0.0 but excludes 1.0.

Implemented in RandomGSL, Ran3, and RandomStd.

virtual double gaussian ( void  )
pure virtual

Returns a unit gaussian distributed random number.

Implemented in RandomGSL, Ran3, and RandomStd.

double exponential ( void  )
virtual

Returns an exponential distributed random number with mean one.

Reimplemented in RandomGSL, Ran3, and RandomStd.

References relacs::log().

Referenced by EventData::poisson().

double gamma ( int  a)
virtual

Returns a gamma distributed random number p(x) dx = x^(a-1) exp(-x)/Gamma(a) dx.

Reimplemented in Ran3, and RandomStd.

References relacs::exp(), relacs::log(), and relacs::sqrt().

virtual string name ( void  )
pure virtual

The name of the random number generator.

Implemented in RandomGSL, Ran3, and RandomStd.


The documentation for this class was generated from the following files: