MUQ  0.4.3
muq::Utilities::RandomGenerator Class Reference

#include <RandomGenerator.h>

Detailed Description

The RandGen generator class is a wrapper around the std::random number generation library. The point of this class is to provide a super easy to use interface for generating Random numbers of canonical scalar distributions (e.g., Uniform, Gaussian, Gamma, Uniform Integer, etc...

Definition at line 34 of file RandomGenerator.h.

Public Types

typedef std::mt19937 GeneratorType
 

Static Public Member Functions

static double GetNormal ()
 
static Eigen::MatrixXd GetNormal (int rows)
 
static Eigen::MatrixXd GetNormal (int rows, int cols)
 
static double GetUniform ()
 
static Eigen::MatrixXd GetUniform (int rows)
 
static Eigen::MatrixXd GetUniform (int rows, int cols)
 
static double GetGamma (double const alpha, double const beta)
 
static Eigen::MatrixXd GetGamma (double const alpha, double const beta, int rows)
 
static Eigen::MatrixXd GetGamma (double const alpha, double const beta, int rows, int cols)
 
static int GetUniformInt (int lb, int ub)
 
static Eigen::MatrixXi GetUniformInt (int lb, int ub, int rows)
 
static Eigen::MatrixXi GetUniformInt (int lb, int ub, int rows, bool unique)
 
static Eigen::MatrixXi GetUniformInt (int lb, int ub, int rows, int cols)
 
static Eigen::MatrixXi GetUniformInt (int lb, int ub, int rows, int cols, bool unique)
 
static int GetDiscrete (std::vector< double > const &discProbs)
 
static int GetDiscrete (Eigen::Ref< const Eigen::VectorXd > const &discProbs)
 
static Eigen::MatrixXi GetDiscrete (std::vector< double > const &discProbs, int rows, int cols=1)
 
static Eigen::MatrixXi GetDiscrete (Eigen::Ref< const Eigen::VectorXd > const &discProbs, int rows, int cols=1)
 
static void SetSeed (int seedval)
 Set the seed for the random number generator. This is a fairly low quality way to do this, but is fine for testing. More...
 
static GeneratorType CopyGenerator ()
 Store a copy of the generator, designed for use with SetGenerator. Be very careful in using this, or you could wreck the library's access to random numbers. More...
 
static void SetGenerator (GeneratorType)
 Set the state of the generator, designed for use with CopyGenerator. Be very careful in using this, or you could wreck the library's access to random numbers. More...
 

Member Typedef Documentation

◆ GeneratorType

Definition at line 37 of file RandomGenerator.h.

Member Function Documentation

◆ CopyGenerator()

RandomGenerator::GeneratorType RandomGenerator::CopyGenerator ( )
static

Store a copy of the generator, designed for use with SetGenerator. Be very careful in using this, or you could wreck the library's access to random numbers.

Definition at line 158 of file RandomGenerator.cpp.

References GetGenerator().

◆ GetDiscrete() [1/4]

int RandomGenerator::GetDiscrete ( Eigen::Ref< const Eigen::VectorXd > const &  discProbs)
static

Definition at line 173 of file RandomGenerator.cpp.

References GetUniform().

◆ GetDiscrete() [2/4]

Eigen::MatrixXi RandomGenerator::GetDiscrete ( Eigen::Ref< const Eigen::VectorXd > const &  discProbs,
int  rows,
int  cols = 1 
)
static

Definition at line 192 of file RandomGenerator.cpp.

References GetUniform(), and nlohmann::detail::dtoa_impl::k.

◆ GetDiscrete() [3/4]

int RandomGenerator::GetDiscrete ( std::vector< double > const &  discProbs)
static

Sample a discrete distribution with replacement.

Definition at line 168 of file RandomGenerator.cpp.

Referenced by GetDiscrete().

◆ GetDiscrete() [4/4]

Eigen::MatrixXi RandomGenerator::GetDiscrete ( std::vector< double > const &  discProbs,
int  rows,
int  cols = 1 
)
static

Definition at line 187 of file RandomGenerator.cpp.

References GetDiscrete().

◆ GetGamma() [1/3]

double RandomGenerator::GetGamma ( double const  alpha,
double const  beta 
)
static

Definition at line 52 of file RandomGenerator.cpp.

References GetGenerator().

Referenced by GetGamma().

◆ GetGamma() [2/3]

static Eigen::MatrixXd muq::Utilities::RandomGenerator::GetGamma ( double const  alpha,
double const  beta,
int  rows 
)
inlinestatic

Definition at line 50 of file RandomGenerator.h.

References GetGamma().

Referenced by GetGamma().

◆ GetGamma() [3/3]

Eigen::MatrixXd RandomGenerator::GetGamma ( double const  alpha,
double const  beta,
int  rows,
int  cols 
)
static

Definition at line 58 of file RandomGenerator.cpp.

References GetGamma().

◆ GetGenerator()

◆ GetNormal() [1/3]

double RandomGenerator::GetNormal ( )
static

Get a standard Gaussian distribution sample.

Definition at line 37 of file RandomGenerator.cpp.

References GetGenerator().

Referenced by muq::Modeling::LinearSDE::EvolveState(), and GetNormal().

◆ GetNormal() [2/3]

static Eigen::MatrixXd muq::Utilities::RandomGenerator::GetNormal ( int  rows)
inlinestatic

Definition at line 41 of file RandomGenerator.h.

References GetNormal().

Referenced by GetNormal().

◆ GetNormal() [3/3]

Eigen::MatrixXd RandomGenerator::GetNormal ( int  rows,
int  cols 
)
static

Definition at line 141 of file RandomGenerator.cpp.

References GetNormal(), and nlohmann::detail::dtoa_impl::n.

◆ GetUniform() [1/3]

double RandomGenerator::GetUniform ( )
static

Get a uniformly distributed real sample in [0,1).

Definition at line 45 of file RandomGenerator.cpp.

References GetGenerator().

Referenced by GetDiscrete(), and GetUniform().

◆ GetUniform() [2/3]

static Eigen::MatrixXd muq::Utilities::RandomGenerator::GetUniform ( int  rows)
inlinestatic

Definition at line 46 of file RandomGenerator.h.

References GetUniform().

Referenced by GetUniform().

◆ GetUniform() [3/3]

Eigen::MatrixXd RandomGenerator::GetUniform ( int  rows,
int  cols 
)
static

Definition at line 127 of file RandomGenerator.cpp.

References GetUniform().

◆ GetUniformInt() [1/5]

int RandomGenerator::GetUniformInt ( int  lb,
int  ub 
)
static

Get a random integer, distributed uniformly, between the bounds.

Definition at line 76 of file RandomGenerator.cpp.

References GetGenerator().

Referenced by GetUniformInt().

◆ GetUniformInt() [2/5]

static Eigen::MatrixXi muq::Utilities::RandomGenerator::GetUniformInt ( int  lb,
int  ub,
int  rows 
)
inlinestatic

Definition at line 55 of file RandomGenerator.h.

References GetUniformInt().

Referenced by GetUniformInt().

◆ GetUniformInt() [3/5]

static Eigen::MatrixXi muq::Utilities::RandomGenerator::GetUniformInt ( int  lb,
int  ub,
int  rows,
bool  unique 
)
inlinestatic

Definition at line 56 of file RandomGenerator.h.

References GetUniformInt().

Referenced by GetUniformInt().

◆ GetUniformInt() [4/5]

static Eigen::MatrixXi muq::Utilities::RandomGenerator::GetUniformInt ( int  lb,
int  ub,
int  rows,
int  cols 
)
inlinestatic

Definition at line 57 of file RandomGenerator.h.

References GetUniformInt().

Referenced by GetUniformInt().

◆ GetUniformInt() [5/5]

Eigen::MatrixXi RandomGenerator::GetUniformInt ( int  lb,
int  ub,
int  rows,
int  cols,
bool  unique 
)
static

Generate N unique random integers from the range lb, ub

Definition at line 85 of file RandomGenerator.cpp.

References GetUniformInt().

◆ SetGenerator()

void RandomGenerator::SetGenerator ( GeneratorType  state)
static

Set the state of the generator, designed for use with CopyGenerator. Be very careful in using this, or you could wreck the library's access to random numbers.

Definition at line 163 of file RandomGenerator.cpp.

References GetGenerator().

◆ SetSeed()

void RandomGenerator::SetSeed ( int  seedval)
static

Set the seed for the random number generator. This is a fairly low quality way to do this, but is fine for testing.

Definition at line 153 of file RandomGenerator.cpp.

References GetGenerator().

Referenced by muq::Utilities::RandomGeneratorTemporarySetSeed::RandomGeneratorTemporarySetSeed().

Member Data Documentation

◆ RandomGeneratorTemporarySetSeed

friend muq::Utilities::RandomGenerator::RandomGeneratorTemporarySetSeed
private

Definition at line 79 of file RandomGenerator.h.


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