12 #ifndef _H_SST_CORE_RNG_GAUSSIAN
13 #define _H_SST_CORE_RNG_GAUSSIAN
20 using namespace SST::RNG;
62 baseDistrib = baseRNG;
65 deleteDistrib =
false;
86 double gauss_u, gauss_v, sq_sum;
89 gauss_u = baseDistrib->nextUniform();
90 gauss_v = baseDistrib->nextUniform();
91 sq_sum = (gauss_u * gauss_u) + (gauss_v * gauss_v);
92 }
while(sq_sum >= 1 || sq_sum == 0);
94 if(baseDistrib->nextUniform() < 0.5) {
98 if(baseDistrib->nextUniform() < 0.5) {
102 double multiplier = sqrt(-2.0 * log(sq_sum) / sq_sum);
103 unusedPair = mean + stddev * gauss_v * multiplier;
106 return mean + stddev * gauss_u * multiplier;
Base class of statistical distributions in SST.
Definition: distrib.h:24
double getStandardDev()
Gets the standard deviation of the distribution.
Definition: gaussian.h:122
double getMean()
Gets the mean of the distribution.
Definition: gaussian.h:114
~SSTGaussianDistribution()
Destroys the Gaussian distribution.
Definition: gaussian.h:71
bool deleteDistrib
Controls whether the destructor deletes the distribution (we need to ensure we do this IF we created ...
Definition: gaussian.h:151
double stddev
The standard deviation of the Gaussian distribution.
Definition: gaussian.h:134
Implements a Mersenne-based RNG for use in the SST core or components.
Definition: mersenne.h:34
Creates a Gaussian (normal) distribution for which to sample.
Definition: gaussian.h:30
bool usePair
Random numbers for the distribution are read in pairs, this tells the code to use the second of the p...
Definition: gaussian.h:146
SSTGaussianDistribution(double mn, double sd)
Creates a new distribution with a predefined random number generator with a specified mean and standa...
Definition: gaussian.h:38
SSTGaussianDistribution(double mn, double sd, SSTRandom *baseRNG)
Creates a new distribution with a predefined random number generator with a specified mean and standa...
Definition: gaussian.h:56
double getNextDouble()
Gets the next double value in the distribution.
Definition: gaussian.h:81
SSTRandom * baseDistrib
The base random number generator for the distribution.
Definition: gaussian.h:138
double unusedPair
Random numbers for the distribution are read in pairs, this stores the second of the pair...
Definition: gaussian.h:142
Implements the base class for random number generators for the SST core.
Definition: sstrng.h:27
double mean
The mean of the Gaussian distribution.
Definition: gaussian.h:130