SG++-Doxygen-Documentation
sgpp::optimization::RandomNumberGenerator Class Reference

Singleton class for generating pseudo-random numbers (wrapper around std::mt19937 from <random>). More...

#include <RandomNumberGenerator.hpp>

Public Types

typedef std::mt19937::result_type SeedType
 type of the seed More...
 

Public Member Functions

double getGaussianRN (double mean=0.0, double stdDev=1.0)
 Generate a Gaussian pseudo-random number. More...
 
void getGaussianRV (base::DataVector &vector, double mean=0.0, double stdDev=1.0)
 Fills vector with Gaussian pseudo-random numbers. More...
 
SeedType getSeed () const
 
size_t getUniformIndexRN (size_t size)
 Generate a uniform pseudo-random array index. More...
 
double getUniformRN (double a=0.0, double b=1.0)
 Generate a uniform pseudo-random number. More...
 
void getUniformRV (base::DataVector &vector, double a=0.0, double b=1.0)
 Fills vector with uniform pseudo-random numbers. More...
 
void setSeed ()
 Reseeds with time-dependent seed. More...
 
void setSeed (SeedType seed)
 Reseeds. More...
 

Static Public Member Functions

static RandomNumberGeneratorgetInstance ()
 

Protected Attributes

std::mt19937 generator
 random number generator More...
 
SeedType seed
 seed More...
 

Detailed Description

Singleton class for generating pseudo-random numbers (wrapper around std::mt19937 from <random>).

Member Typedef Documentation

◆ SeedType

typedef std::mt19937::result_type sgpp::optimization::RandomNumberGenerator::SeedType

type of the seed

Member Function Documentation

◆ getGaussianRN()

double sgpp::optimization::RandomNumberGenerator::getGaussianRN ( double  mean = 0.0,
double  stdDev = 1.0 
)

Generate a Gaussian pseudo-random number.

Parameters
meanmean of the Gaussian distribution
stdDevstandard deviation of the Gaussian distribution
Returns
Gaussian pseudo-random number

References generator.

Referenced by sgpp::optimization::test_problems::UnconstrainedTestProblem::generateDisplacement(), sgpp::optimization::test_problems::ConstrainedTestProblem::generateDisplacement(), getGaussianRV(), and sgpp::optimization::optimizer::CMAES::optimize().

◆ getGaussianRV()

void sgpp::optimization::RandomNumberGenerator::getGaussianRV ( base::DataVector vector,
double  mean = 0.0,
double  stdDev = 1.0 
)

Fills vector with Gaussian pseudo-random numbers.

Parameters
[out]vectorvector to be filled, has to have desired size beforehand
meanmean of the Gaussian distribution
stdDevstandard deviation of the Gaussian distribution

References getGaussianRN(), sgpp::base::DataVector::getSize(), and python.statsfileInfo::i.

◆ getInstance()

◆ getSeed()

RandomNumberGenerator::SeedType sgpp::optimization::RandomNumberGenerator::getSeed ( ) const
Returns
seed

References seed.

◆ getUniformIndexRN()

size_t sgpp::optimization::RandomNumberGenerator::getUniformIndexRN ( size_t  size)

Generate a uniform pseudo-random array index.

Parameters
sizesize of the array
Returns
discrete uniform pseudo-random number in \(\{0, \dotsc, \text{\texttt{size}} - 1\}\)

References generator.

Referenced by sgpp::optimization::optimizer::DifferentialEvolution::optimize().

◆ getUniformRN()

double sgpp::optimization::RandomNumberGenerator::getUniformRN ( double  a = 0.0,
double  b = 1.0 
)

Generate a uniform pseudo-random number.

Parameters
alower bound
bupper bound
Returns
uniform pseudo-random number in \([a, b]\)

References generator.

Referenced by getUniformRV(), sgpp::optimization::optimizer::DifferentialEvolution::optimize(), and sgpp::optimization::optimizer::MultiStart::optimize().

◆ getUniformRV()

void sgpp::optimization::RandomNumberGenerator::getUniformRV ( base::DataVector vector,
double  a = 0.0,
double  b = 1.0 
)

Fills vector with uniform pseudo-random numbers.

Parameters
[out]vectorvector to be filled, has to have desired size beforehand
alower bound
bupper bound

References sgpp::base::DataVector::getSize(), getUniformRN(), and python.statsfileInfo::i.

◆ setSeed() [1/2]

void sgpp::optimization::RandomNumberGenerator::setSeed ( )

Reseeds with time-dependent seed.

◆ setSeed() [2/2]

void sgpp::optimization::RandomNumberGenerator::setSeed ( RandomNumberGenerator::SeedType  seed)

Reseeds.

Parameters
seedseed to be used

References generator, and seed.

Member Data Documentation

◆ generator

std::mt19937 sgpp::optimization::RandomNumberGenerator::generator
protected

random number generator

Referenced by getGaussianRN(), getUniformIndexRN(), getUniformRN(), and setSeed().

◆ seed

SeedType sgpp::optimization::RandomNumberGenerator::seed
protected

seed

Referenced by getSeed(), and setSeed().


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