dlr::random::PseudoRandom Class Reference

The PseudoRandom class generates psuedo-random numbers. More...

#include <pseudoRandom.h>

List of all members.

Public Member Functions

 PseudoRandom ()
 The default constructor initializes the random number generator with a seed derived from the system clock.
 PseudoRandom (Int64 seed)
 This constructor sets the seed of the random number generator.
 ~PseudoRandom ()
 The destructor cleans up any allocated resources.
double gaussian (double mu, double sigma)
 This member function returns a double drawn from a Gaussian distribution with the specified mean and standard deviation.
Int64 getCurrentSeed ()
 This member function returns the current state of the random number generator.
double normal ()
 This member function returns a double drawn from a Gaussian distribution with mean equal to 0.0 and and standard deviation equal to 1.0.
void setCurrentSeed (Int64 seed)
 This member function sets the seed for the random number generator.
double uniform (double lowerBound, double upperBound)
 This member function returns a double, x, drawn from a uniform distribution with bounds such that:.
int uniformInt (int lowerBound, int upperBound)
 This member function returns a integer, x, drawn from a uniform distribution with bounds such that:.


Detailed Description

The PseudoRandom class generates psuedo-random numbers.

Definition at line 30 of file pseudoRandom.h.


Constructor & Destructor Documentation

dlr::random::PseudoRandom::PseudoRandom (  ) 

The default constructor initializes the random number generator with a seed derived from the system clock.

If you create two PseudoRandom instances with a millisecond or so of each other, you may want to check that they have different seeds by calling the getCurrentSeed() member function.

Definition at line 27 of file pseudoRandom.cpp.

References dlr::portability::getCurrentTime().

dlr::random::PseudoRandom::PseudoRandom ( Int64  seed  ) 

This constructor sets the seed of the random number generator.

This is useful if you need a repeatable sequence of pseudo-random numbers.

Parameters:
seed This argument is a long long integer. Note that currently only the low-order 47 bits are used. The remaining bits are ignored.

Definition at line 66 of file pseudoRandom.cpp.

References setCurrentSeed().

dlr::random::PseudoRandom::~PseudoRandom (  )  [inline]

The destructor cleans up any allocated resources.

Definition at line 58 of file pseudoRandom.h.


Member Function Documentation

double dlr::random::PseudoRandom::gaussian ( double  mu,
double  sigma 
)

This member function returns a double drawn from a Gaussian distribution with the specified mean and standard deviation.

Parameters:
mu This argument specifies the mean of the desired distribution.
sigma This argument specifies the standard deviation of the desired distribution.
Returns:
The return value is a sample drawn from a Gaussian distribution.

Definition at line 76 of file pseudoRandom.cpp.

References normal().

Int64 dlr::random::PseudoRandom::getCurrentSeed (  ) 

This member function returns the current state of the random number generator.

Note that the result of this call will change each time a random number is generated. You can pick up at any given place in the sequence of random numbers by recording the seed at that point and setting it later.

Returns:
The return value is a long long int. Currently only the low-order 47 bits are meaningful. The remaining bits will be set to zero.

Definition at line 87 of file pseudoRandom.cpp.

double dlr::random::PseudoRandom::normal (  ) 

This member function returns a double drawn from a Gaussian distribution with mean equal to 0.0 and and standard deviation equal to 1.0.

Returns:
The return value is a sample drawn from a normal distribution.

Definition at line 103 of file pseudoRandom.cpp.

References dlarnv_().

Referenced by gaussian().

void dlr::random::PseudoRandom::setCurrentSeed ( Int64  seed  ) 

This member function sets the seed for the random number generator.

This is useful if you need a repeatable sequence of pseudoRandom numbers.

Parameters:
seed This argument is a long long integer. Note that currently only the low-order 47 bits are used. The remaining bits are ignored.

Definition at line 120 of file pseudoRandom.cpp.

Referenced by PseudoRandom().

double dlr::random::PseudoRandom::uniform ( double  lowerBound,
double  upperBound 
)

This member function returns a double, x, drawn from a uniform distribution with bounds such that:.

lowerBound <= x < upperBound

Parameters:
lowerBound This argument specifies the lower bound of the uniform distribution.
upperBound This argument specifies the upper bound of the uniform distribution.
Returns:
The return value is a sample drawn from a uniform distribution.

Definition at line 142 of file pseudoRandom.cpp.

References dlarnv_(), and dlr::numeric::range().

Referenced by uniformInt().

int dlr::random::PseudoRandom::uniformInt ( int  lowerBound,
int  upperBound 
)

This member function returns a integer, x, drawn from a uniform distribution with bounds such that:.

lowerBound <= x < upperBound

Parameters:
lowerBound This argument specifies the lower bound of the uniform distribution.
upperBound This argument specifies the upper bound of the uniform distribution.
Returns:
The return value is a sample drawn from a uniform distribution.

Definition at line 161 of file pseudoRandom.cpp.

References uniform().


The documentation for this class was generated from the following files:
Generated on Mon Jul 9 20:34:22 2007 for dlrLibs Utility Libraries by  doxygen 1.5.2