RepastHPC  2.3.1
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
repast::Random Class Reference

Methods for working with random distributions, draws etc. More...

#include <Random.h>

Public Member Functions

void putGenerator (const std::string &id, NumberGenerator *generator)
 Puts the named generator into this Random. More...
 
NumberGeneratorgetGenerator (const std::string &id)
 Gets the named generator or 0 if the name is not found. More...
 
boost::mt19937 & engine ()
 Gets the random number engine from which the distributions are created. More...
 
double nextDouble ()
 Gets the current seed. More...
 
DoubleUniformGenerator createUniDoubleGenerator (double from, double to)
 Creates a generator that produces doubles in the range [from, to). More...
 
IntUniformGenerator createUniIntGenerator (int from, int to)
 Creates a generator that produces ints in the range [from, to]. More...
 
TriangleGenerator createTriangleGenerator (double lowerBound, double mostLikely, double upperBound)
 Creates a triangle generator with the specified properties. More...
 
CauchyGenerator createCauchyGenerator (double median, double sigma)
 pdf: p(x) = sigma/(pi*(sigma**2 + (x-median)**2)) More...
 
ExponentialGenerator createExponentialGenerator (double lambda)
 pdf: p(x) = lambda * exp(-lambda * x) More...
 
NormalGenerator createNormalGenerator (double mean, double sigma)
 Creates a normal generator. More...
 
LogNormalGenerator createLogNormalGenerator (double mean, double sigma)
 Produces random numbers with p(x) = 1/(x * normal_sigma * sqrt(2*pi)) * exp( -(log(x)-normal_mean)2 / (2*normal_sigma2) ) for x > 0, where normal_mean = log(mean2/sqrt(sigma2 + mean2)) and normal_sigma = sqrt(log(1 + sigma2/mean2))
 

Static Public Member Functions

static void initialize (boost::uint32_t seed)
 Initialize the Random singleton with the specified seed. More...
 
static void initialize (boost::mt19937 generator)
 Initialize the Random singleton with random number generator. More...
 
static Randominstance ()
 Gets the singleton instance of this Random.
 

Protected Member Functions

 Random (boost::uint32_t seed)
 
 Random (boost::mt19937 generator)
 

Detailed Description

Methods for working with random distributions, draws etc.

Member Function Documentation

◆ createCauchyGenerator()

CauchyGenerator repast::Random::createCauchyGenerator ( double  median,
double  sigma 
)

pdf: p(x) = sigma/(pi*(sigma**2 + (x-median)**2))

Parameters
median
sigma
Returns
a Cauchy generator.

◆ createExponentialGenerator()

ExponentialGenerator repast::Random::createExponentialGenerator ( double  lambda)

pdf: p(x) = lambda * exp(-lambda * x)

Parameters
lambdamust be > 0
Returns
an exponential generator.

◆ createNormalGenerator()

NormalGenerator repast::Random::createNormalGenerator ( double  mean,
double  sigma 
)

Creates a normal generator.

pdf: p(x) = 1/sqrt(2*pi*sigma) * exp(- (x-mean)2 / (2*sigma2) )

◆ createTriangleGenerator()

TriangleGenerator repast::Random::createTriangleGenerator ( double  lowerBound,
double  mostLikely,
double  upperBound 
)

Creates a triangle generator with the specified properties.

A TriangleGenerator produces a floating point value x where lowerbound <= x <= upperBound and mostLikely is the most probable value for x.

Parameters
lowerBoundthe lower bound of the values produced by the generator
mostLikelythe most likely value produced by the generator
upperBoundthe upper bound of the values produced by the generator
Returns
a triangle generator.

◆ createUniDoubleGenerator()

DoubleUniformGenerator repast::Random::createUniDoubleGenerator ( double  from,
double  to 
)

Creates a generator that produces doubles in the range [from, to).

inclusive of from, exclusive of to.

Parameters
fromthe range start (inclusive)
tothe range end (exclusive)
Returns
a generator that produces doubles in the range [from, to).

◆ createUniIntGenerator()

IntUniformGenerator repast::Random::createUniIntGenerator ( int  from,
int  to 
)

Creates a generator that produces ints in the range [from, to].

Parameters
fromthe range start (inclusive)
tothe range end (inclusive)
Returns
a generator that produces ints in the range [from, to].

◆ engine()

boost::mt19937& repast::Random::engine ( )
inline

Gets the random number engine from which the distributions are created.

Returns
he random number engine from which the distributions are created.

◆ getGenerator()

NumberGenerator * repast::Random::getGenerator ( const std::string &  id)

Gets the named generator or 0 if the name is not found.

Parameters
idthe name of the generator to get

◆ initialize() [1/2]

void repast::Random::initialize ( boost::mt19937  generator)
static

Initialize the Random singleton with random number generator.

Parameters
generatorthe random number generator

◆ initialize() [2/2]

static void repast::Random::initialize ( boost::uint32_t  seed)
static

Initialize the Random singleton with the specified seed.

Parameters
seedthe seed to initialize the random number generator with.

◆ nextDouble()

double repast::Random::nextDouble ( )

Gets the current seed.

Returns
the current seed.

boost::uint32_t seed() { return seed; } Gets the next double in the range [0, 1).

Returns
the next double in the range [0, 1).

◆ putGenerator()

void repast::Random::putGenerator ( const std::string &  id,
NumberGenerator generator 
)

Puts the named generator into this Random.

Added generators will be deleted by Random when it is destroyed.

Parameters
theid of the generator
generatorthe generator to add

The documentation for this class was generated from the following files: