Random Class Reference

#include <Random.h>

List of all members.

Public Member Functions

 Random ()
 ~Random ()
 Random (long seed)
 Random (const Random &rhs)
void initialize (long seed, int rank)
 This is called to initialize a Random object.
void reset ()
 This will clear the internal variables of the RNG.
void printStream (ostream &strm)
 Print the current status of the random number generator.
void writeXML (ostream &strm)
 Checkpoint the Random object.
bool readXML (istream &strm)
 Recover a checkpointed Random object.
int intdev ()
 This will generate a random integer with a uniform deviation.
double unidev ()
 This will generate a random number with a uniform deviation.
double gasdev ()
 Generates a gaussian distributed random number with unit variance using the gasdev algorithm from numerical recipes.
double expdev ()
 Generates an exponentially distributed random number whith the probability distribution function

\[ p(x)dx = e^{-x}dx. \]

To generate points according to

\[ p(x)dx = a e^{-a*x}dx \]

divide the result of this function by $a$.

double sindev ()
 Generates a random number distributed with the probability distribution function

\[ p(x)dx = \frac{1}{2}\sin(x)dx. \]

The random variable is a number in $[0,\Pi]$.

double sindev (double u)
double randomDistribution1 ()
 Generates a random number distributed whith the probability distribution function

\[ p(x)dx = \frac{1}{2}x^{2}e^{-x}dx. \]

The random variable is a number on the positive real axis.

double pdf2 (double a, double zeta, double x)
 Generates a random number distributed with the probability distribution function using a rejection type algorithm.
double randomDistribution2 (double a, double zeta, double min, double max)
double randomDistribution3 (double F)

Private Member Functions

double ran1 (long *idum)
 Generates a uniform random number on $[0,1]$ using the ran1 algorithm from numerical recipes.

Private Attributes

long start
 Store the initial value for the seed.
long current
 When using ran1, this represents the current state of the initial seed.
long iy
long iv [NTAB]


Detailed Description

Definition at line 45 of file Random.h.


Constructor & Destructor Documentation

Random::Random (  ) 

Definition at line 15 of file Random.cpp.

Random::~Random (  ) 

Definition at line 45 of file Random.cpp.

Random::Random ( long  seed  ) 

Definition at line 22 of file Random.cpp.

References initialize().

Random::Random ( const Random rhs  ) 

Definition at line 30 of file Random.cpp.

References current, iv, iy, NTAB, and start.


Member Function Documentation

double Random::ran1 ( long *  idum  )  [private]

Generates a uniform random number on $[0,1]$ using the ran1 algorithm from numerical recipes.

"Minimal" random number generator of Park and Miller with Bays-Durham shuffle and added safeguards. Returns a uniform random deviate between 0.0 and 1.0, exclusive of the end point values. Call with *idum a negative number to initialize, and thereafter do not alter *idum between sucessive deviates in a sequence. RNMX should approximate the largest floating value that is less than 1.

Parameters:
idum random number seed
Returns:
uniform random number on $[0,1]$.

Definition at line 391 of file Random.cpp.

References AM, IA, IM, IQ, IR, iv, iy, NDIV, NTAB, and RNMX.

Referenced by intdev(), and unidev().

void Random::initialize ( long  seed,
int  rank 
)

This is called to initialize a Random object.

Parameters:
seed is the seed used for the stream of random numbers
rank is used to generate a different seed for each processor, ignored if SPRNG is available.

Definition at line 53 of file Random.cpp.

References current, intdev(), reset(), and start.

Referenced by QMCManager::initializeCalculationState(), and Random().

void Random::reset (  ) 

This will clear the internal variables of the RNG.

Definition at line 123 of file Random.cpp.

References iv, iy, and NTAB.

Referenced by initialize().

void Random::printStream ( ostream &  strm  ) 

Print the current status of the random number generator.

Parameters:
strm A strm to print to.

Definition at line 134 of file Random.cpp.

References current.

void Random::writeXML ( ostream &  strm  ) 

Checkpoint the Random object.

Parameters:
strm where to write the checkpoint data

Definition at line 145 of file Random.cpp.

References current, iv, iy, and NTAB.

Referenced by QMCManager::writeXML().

bool Random::readXML ( istream &  strm  ) 

Recover a checkpointed Random object.

Parameters:
strm where the stream info is available to be read.
Returns:
whether the read was successful

Definition at line 162 of file Random.cpp.

References current, iv, iy, and NTAB.

Referenced by QMCManager::readXML().

int Random::intdev (  ) 

This will generate a random integer with a uniform deviation.

If the SPRNG library is available, it will be used.

Returns:
uniform random number on $[0,INT_MAX]$.

Definition at line 212 of file Random.cpp.

References current, and ran1().

Referenced by initialize().

double Random::unidev (  ) 

double Random::gasdev (  ) 

Generates a gaussian distributed random number with unit variance using the gasdev algorithm from numerical recipes.

To generate a gaussian random number with another variance, multiply this result by the desired standard deviation.

Returns:
gaussian random number with unit variance

Definition at line 231 of file Random.cpp.

References current, and unidev().

Referenced by QMCMikesJackedWalkerInitialization::initializeWalkerPosition(), QMCAmosBoringWalkerInitialization::initializeWalkerPosition(), AtomicOrbitalInverter::invert_gaussians(), QMCWalker::moveElectronsImportanceSampling(), QMCWalker::moveElectronsNoImportanceSampling(), QMCWalker::moveElectronsUmrigar93ImportanceSampling(), and CKGeneticAlgorithm1::mutate().

double Random::expdev (  ) 

Generates an exponentially distributed random number whith the probability distribution function

\[ p(x)dx = e^{-x}dx. \]

To generate points according to

\[ p(x)dx = a e^{-a*x}dx \]

divide the result of this function by $a$.

The random variable is a number on the positive real axis.

This method was developed by David Randall ``Chip'' Kent IV and works by directly inverting the distribution.

Returns:
exponential random number

Definition at line 259 of file Random.cpp.

References unidev().

Referenced by randomDistribution1().

double Random::sindev (  ) 

Generates a random number distributed with the probability distribution function

\[ p(x)dx = \frac{1}{2}\sin(x)dx. \]

The random variable is a number in $[0,\Pi]$.

This method was developed by David Randall ``Chip'' Kent IV and works by directly inverting the distribution.

Returns:
random number distributed with respect to $\sin(x)/2$.

Definition at line 264 of file Random.cpp.

References unidev().

Referenced by QMCDansWalkerInitialization::dist_energy_level(), QMCDansWalkerInitialization::generateThetaCoordinate(), QMCWalker::moveElectronsUmrigar93AcceleratedSampling(), and QMCWalker::moveElectronsUmrigar93ImportanceSampling().

double Random::sindev ( double  u  ) 

Definition at line 269 of file Random.cpp.

References unidev().

double Random::randomDistribution1 (  ) 

Generates a random number distributed whith the probability distribution function

\[ p(x)dx = \frac{1}{2}x^{2}e^{-x}dx. \]

The random variable is a number on the positive real axis.

This method was developed by David Randall ``Chip'' Kent IV and works by using a rejection type algorithm.

Returns:
random number distributed with respect to $x^{2}e^{-x}/2$.

Definition at line 283 of file Random.cpp.

References expdev(), and unidev().

Referenced by QMCWalker::moveElectronsUmrigar93ImportanceSampling().

double Random::pdf2 ( double  a,
double  zeta,
double  x 
)

Generates a random number distributed with the probability distribution function using a rejection type algorithm.

\[ p(x)dx = sqrt(x) ( 1 + a x) e^{- \zeta x}dx. \]

The random variable is a number on the positive real axis.

Returns:
random number distributed with respect to $ sqrt(x) (1 + a x)e^{- \zeta x}$.

Definition at line 296 of file Random.cpp.

Referenced by randomDistribution2().

double Random::randomDistribution2 ( double  a,
double  zeta,
double  min,
double  max 
)

Definition at line 301 of file Random.cpp.

References pdf2(), and unidev().

Referenced by QMCWalker::moveElectronsUmrigar93AcceleratedSampling().

double Random::randomDistribution3 ( double  F  ) 

Definition at line 362 of file Random.cpp.

References unidev().

Referenced by QMCWalker::moveElectronsUmrigar93AcceleratedSampling().


Member Data Documentation

long Random::start [private]

Store the initial value for the seed.

Definition at line 51 of file Random.h.

Referenced by initialize(), and Random().

long Random::current [private]

When using ran1, this represents the current state of the initial seed.

Definition at line 57 of file Random.h.

Referenced by gasdev(), initialize(), intdev(), printStream(), Random(), readXML(), unidev(), and writeXML().

long Random::iy [private]

Definition at line 68 of file Random.h.

Referenced by ran1(), Random(), readXML(), reset(), and writeXML().

long Random::iv[NTAB] [private]

Definition at line 69 of file Random.h.

Referenced by ran1(), Random(), readXML(), reset(), and writeXML().


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

Generated on Sat Jul 5 16:14:07 2008 for QMcBeaver by  doxygen 1.5.6