NOMAD Source  Version 4.0.0 Beta
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RNG Class Reference

Brief Class for random number generator. More...

#include <RNG.hpp>

Static Public Member Functions

static int getSeed ()
 Get current seed. More...
 
static void setSeed (int s)
 Set seed. More...
 
static uint32_t rand ()
 Get a random integer as uint32. More...
 
static double rand (double a, double b)
 Get a random number having a normal distribution as double. More...
 
static double normalRandMean0 (double Var=1, int Nsample=12)
 Get a random number using a normal distribution centered on 0. More...
 
static double normalRand (double Mean=0, double Var=1)
 Get a random number approaching a normal distribution N(Mean,Var) as double. More...
 
static void resetPrivateSeedToDefault ()
 Reset seed to its default value. More...
 
static void getPrivateSeed (uint32_t &x, uint32_t &y, uint32_t &z)
 Get private values. More...
 
static void setPrivateSeed (uint32_t x, uint32_t y, uint32_t z)
 Reset seed to given values. More...
 

Static Private Attributes

static uint32_t x_def
 
static uint32_t y_def
 
static uint32_t z_def
 Initial values for the random number generator. More...
 
static uint32_t _x
 
static uint32_t _y
 
static uint32_t _z
 Current values for the random number generator. More...
 
static int _s
 

Detailed Description

Brief Class for random number generator.

This class is used to set a seed for the random number generator and get a random integer or a random double between two values.

Definition at line 25 of file RNG.hpp.

Member Function Documentation

static void RNG::getPrivateSeed ( uint32_t x,
uint32_t y,
uint32_t z 
)
inlinestatic

Get private values.

Definition at line 94 of file RNG.hpp.

95  {
96  x = _x;
97  y = _y;
98  z = _z;
99  }
static uint32_t _z
Current values for the random number generator.
Definition: RNG.hpp:115
static uint32_t _y
Definition: RNG.hpp:115
static uint32_t _x
Definition: RNG.hpp:115
static int RNG::getSeed ( )
inlinestatic

Get current seed.

Definition at line 32 of file RNG.hpp.

33  {
34  return _s;
35  }
static int _s
Definition: RNG.hpp:117
static double RNG::normalRand ( double  Mean = 0,
double  Var = 1 
)
static

Get a random number approaching a normal distribution N(Mean,Var) as double.

/param Mean Mean of the target normal distribution – IN (Opt) (default = 0). /param Var Variance of the target normal distribution – IN (Opt) (default = 1). /return A random number.

static double RNG::normalRandMean0 ( double  Var = 1,
int  Nsample = 12 
)
static

Get a random number using a normal distribution centered on 0.

Get a random number approaching a normal distribution (N(0,Var)) as double A series of Nsample random numbers Xi in the interval [-sqrt(3*Var);+sqrt(3*Var)] is used -> E[Xi] = 0, Var(Xi) = var see http://en.wikipedia.org/wiki/Central_limit_theorem

/param Var Variance of the target normal distribution – IN (Opt) (default =1). /param Nsample Number of samples for averaging – IN (Opt) (default = 12). /return A double in the interval [-sqrt(3*Var);+sqrt(3*Var)].

static uint32_t RNG::rand ( )
static

Get a random integer as uint32.

This function serves to obtain a random number /return An integer in the interval [0,UINT32_MAX].

static double RNG::rand ( double  a,
double  b 
)
inlinestatic

Get a random number having a normal distribution as double.

Definition at line 58 of file RNG.hpp.

59  {
60  return a+((b-a)*RNG::rand())/UINT32_MAX;
61  }
static uint32_t rand()
Get a random integer as uint32.
#define UINT32_MAX
Definition: defines.hpp:44
static void RNG::resetPrivateSeedToDefault ( )
inlinestatic

Reset seed to its default value.

Definition at line 86 of file RNG.hpp.

87  {
88  _x = x_def;
89  _y = y_def;
90  _z = z_def;
91  }
static uint32_t z_def
Initial values for the random number generator.
Definition: RNG.hpp:114
static uint32_t _z
Current values for the random number generator.
Definition: RNG.hpp:115
static uint32_t _y
Definition: RNG.hpp:115
static uint32_t y_def
Definition: RNG.hpp:114
static uint32_t x_def
Definition: RNG.hpp:114
static uint32_t _x
Definition: RNG.hpp:115
static void RNG::setPrivateSeed ( uint32_t  x,
uint32_t  y,
uint32_t  z 
)
inlinestatic

Reset seed to given values.

Used to set back RNG in a known state.

Definition at line 105 of file RNG.hpp.

106  {
107  _x = x;
108  _y = y;
109  _z = z;
110  }
static uint32_t _z
Current values for the random number generator.
Definition: RNG.hpp:115
static uint32_t _y
Definition: RNG.hpp:115
static uint32_t _x
Definition: RNG.hpp:115
static void RNG::setSeed ( int  s)
static

Set seed.

Member Data Documentation

int RNG::_s
staticprivate

Definition at line 117 of file RNG.hpp.

uint32_t RNG::_x
staticprivate

Definition at line 115 of file RNG.hpp.

uint32_t RNG::_y
staticprivate

Definition at line 115 of file RNG.hpp.

uint32_t RNG::_z
staticprivate

Current values for the random number generator.

Definition at line 115 of file RNG.hpp.

uint32_t RNG::x_def
staticprivate

Definition at line 114 of file RNG.hpp.

uint32_t RNG::y_def
staticprivate

Definition at line 114 of file RNG.hpp.

uint32_t RNG::z_def
staticprivate

Initial values for the random number generator.

Definition at line 114 of file RNG.hpp.


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