12 #ifndef SST_CORE_RNG_GAUSSIAN_H 13 #define SST_CORE_RNG_GAUSSIAN_H 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;
176 #endif // SST_CORE_RNG_GAUSSIAN_H Implements the base class for random number generators for the SST core.
Definition: rng.h:29
Definition: constant.h:21
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:35
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:162
bool deleteDistrib
Controls whether the destructor deletes the distribution (we need to ensure we do this IF we created ...
Definition: gaussian.h:168
ImplementSerializable(SST::RNG::GaussianDistribution) protected double stddev
Serialization macro.
Definition: gaussian.h:140
Implements a Mersenne-based RNG for use in the SST core or components.
Definition: mersenne.h:34
~GaussianDistribution()
Destroys the Gaussian distribution.
Definition: gaussian.h:71
SST::RNG::Random * baseDistrib
The base random number generator for the distribution.
Definition: gaussian.h:154
void serialize_order(SST::Core::Serialization::serializer &ser) override
Serialization function for checkpoint.
Definition: gaussian.h:127
double getNextDouble() override
Gets the next double value in the distribution.
Definition: gaussian.h:80
GaussianDistribution()
Default constructor.
Definition: gaussian.h:122
Creates a Gaussian (normal) distribution for which to sample.
Definition: gaussian.h:30
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
double getMean()
Gets the mean of the distribution.
Definition: gaussian.h:111
double getStandardDev()
Gets the standard deviation of the distribution.
Definition: gaussian.h:117
double unusedPair
Random numbers for the distribution are read in pairs, this stores the second of the pair...
Definition: gaussian.h:158
Base class of statistical distributions in SST.
Definition: distrib.h:24
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