12 #ifndef SST_CORE_RNG_DISCRETE_H
13 #define SST_CORE_RNG_DISCRETE_H
22 using namespace SST::RNG;
46 probabilities = (
double*)malloc(
sizeof(
double) * probsCount);
49 for ( uint32_t i = 0; i < probsCount; i++ ) {
50 probabilities[i] = prob_sum;
67 probabilities = (
double*)malloc(
sizeof(
double) * probsCount);
70 for ( uint32_t i = 0; i < probsCount; i++ ) {
71 probabilities[i] = prob_sum;
75 baseDistrib = baseDist;
76 deleteDistrib =
false;
86 if ( deleteDistrib ) {
delete baseDistrib; }
96 const double nextD = baseDistrib->nextUniform();
100 for ( ; index < probCount; index++ ) {
101 if ( probabilities[index] >= nextD ) {
break; }
104 return (
double)index;
134 #endif // SST_CORE_RNG_DISCRETE_H
Implements the base class for random number generators for the SST core.
Definition: rng.h:27
DiscreteDistribution(const double *probs, const uint32_t probsCount, SST::RNG::Random *baseDist)
Creates an exponential distribution with a specific lambda and a base random number generator...
Definition: discrete.h:63
bool deleteDistrib
Controls whether the base distribution should be deleted when this class is destructed.
Definition: discrete.h:116
uint32_t probCount
Count of discrete probabilities.
Definition: discrete.h:126
Creates a discrete distribution for use within SST.
Definition: discrete.h:33
Implements a Mersenne-based RNG for use in the SST core or components.
Definition: mersenne.h:34
double getNextDouble()
Gets the next (random) double value in the distribution.
Definition: discrete.h:94
DiscreteDistribution(const double *probs, const uint32_t probsCount)
Creates an exponential distribution with a specific lambda.
Definition: discrete.h:41
double * probabilities
The discrete probability list.
Definition: discrete.h:121
SST::RNG::Random * baseDistrib
Sets the base random number generator for the distribution.
Definition: discrete.h:111
~DiscreteDistribution()
Destroys the exponential distribution.
Definition: discrete.h:82
Base class of statistical distributions in SST.
Definition: distrib.h:22