#include <Random.h>
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
To generate points according to
| |
double | sindev () |
Generates a random number distributed with the probability distribution function
| |
double | sindev (double u) |
double | randomDistribution1 () |
Generates a random number distributed whith the probability distribution function
| |
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 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] |
Definition at line 45 of file Random.h.
Random::Random | ( | ) |
Definition at line 15 of file Random.cpp.
Random::~Random | ( | ) |
Definition at line 45 of file Random.cpp.
Random::Random | ( | long | seed | ) |
Random::Random | ( | const Random & | rhs | ) |
double Random::ran1 | ( | long * | idum | ) | [private] |
Generates a uniform random number on 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.
idum | random number seed |
Definition at line 391 of file Random.cpp.
References AM, IA, IM, IQ, IR, iv, iy, NDIV, NTAB, and RNMX.
void Random::initialize | ( | long | seed, | |
int | rank | |||
) |
This is called to initialize a Random object.
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.
Referenced by initialize().
void Random::printStream | ( | ostream & | strm | ) |
Print the current status of the random number generator.
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.
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.
strm | where the stream info is available to be read. |
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.
Definition at line 212 of file Random.cpp.
References current, and ran1().
Referenced by initialize().
double Random::unidev | ( | ) |
This will generate a random number with a uniform deviation.
If the SPRNG library is available, it will be used.
Definition at line 222 of file Random.cpp.
References current, and ran1().
Referenced by QMCWalker::acceptOrRejectMove(), QMCRun::ack_reconfiguration(), QMCDansWalkerInitialization::assign_electrons_to_nuclei(), CKGeneticAlgorithm1::crossover(), QMCDansWalkerInitialization::dist_energy_level(), QMCMikesJackedWalkerInitialization::electrons_and_radii(), expdev(), gasdev(), QMCDansWalkerInitialization::generatePhiCoordinate(), QMCDansWalkerInitialization::generateRadialDistances(), QMCDansWalkerInitialization::generateThetaCoordinate(), AtomicOrbitalInverter::get_xyz(), AtomicOrbitalInverter::invert_gaussians(), QMCWalker::moveElectronsUmrigar93ImportanceSampling(), QMCRun::nonunitWeightBranching(), DistributionInverter::random(), randomDistribution1(), randomDistribution2(), randomDistribution3(), QMCNuclearForces::randomlyRotate(), CKGeneticAlgorithm1::selectParent(), sindev(), and QMCRun::unitWeightBranching().
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.
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
To generate points according to
divide the result of this function by .
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.
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
The random variable is a number in .
This method was developed by David Randall ``Chip'' Kent IV and works by directly inverting the distribution.
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 | ) |
double Random::randomDistribution1 | ( | ) |
Generates a random number distributed whith the probability distribution function
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.
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.
The random variable is a number on the positive real axis.
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().
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] |
long Random::iv[NTAB] [private] |