12 #ifndef SST_CORE_RNG_GAUSSIAN_H
13 #define SST_CORE_RNG_GAUSSIAN_H
20 using namespace SST::RNG;
62 baseDistrib = baseRNG;
65 deleteDistrib =
false;
73 if ( deleteDistrib ) {
delete baseDistrib; }
87 double gauss_u, gauss_v, sq_sum;
90 gauss_u = baseDistrib->nextUniform();
91 gauss_v = baseDistrib->nextUniform();
92 sq_sum = (gauss_u * gauss_u) + (gauss_v * gauss_v);
93 }
while ( sq_sum >= 1 || sq_sum == 0 );
95 if ( baseDistrib->nextUniform() < 0.5 ) { gauss_u *= -1.0; }
97 if ( baseDistrib->nextUniform() < 0.5 ) { gauss_v *= -1.0; }
99 double multiplier = sqrt(-2.0 * log(sq_sum) / sq_sum);
100 unusedPair = mean + stddev * gauss_v * multiplier;
103 return mean + stddev * gauss_u * multiplier;
Creates a Gaussian (normal) distribution for which to sample.
Definition: gaussian.h:31
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:139
GaussianDistribution(double mn, double sd, SST::RNG::Random *baseRNG)
Creates a new distribution with a predefined random number generator with a specified mean and standa...
Definition: gaussian.h:56
~GaussianDistribution()
Destroys the Gaussian distribution.
Definition: gaussian.h:71
double getMean()
Gets the mean of the distribution.
Definition: gaussian.h:111
double getNextDouble()
Gets the next double value in the distribution.
Definition: gaussian.h:80
SST::RNG::Random * baseDistrib
The base random number generator for the distribution.
Definition: gaussian.h:131
double mean
The mean of the Gaussian distribution.
Definition: gaussian.h:123
bool deleteDistrib
Controls whether the destructor deletes the distribution (we need to ensure we do this IF we created ...
Definition: gaussian.h:145
GaussianDistribution(double mn, double sd)
Creates a new distribution with a predefined random number generator with a specified mean and standa...
Definition: gaussian.h:39
double unusedPair
Random numbers for the distribution are read in pairs, this stores the second of the pair.
Definition: gaussian.h:135
double getStandardDev()
Gets the standard deviation of the distribution.
Definition: gaussian.h:117
double stddev
The standard deviation of the Gaussian distribution.
Definition: gaussian.h:127
Implements a Mersenne-based RNG for use in the SST core or components.
Definition: mersenne.h:35
Base class of statistical distributions in SST.
Definition: distrib.h:23
Implements the base class for random number generators for the SST core.
Definition: rng.h:28