Random number generators


Files

file  rndgen.h
 Random number generator stub functions and classes.

Classes

class  UniformDETimeRndGen
 uniform DETime random generator More...
class  ExponentialDETimeRndGen
 exponential DETime random generator More...
class  UniformDoubleRndGen
 uniform double random generator More...
class  UniformIntRndGen
 uniform long int random generator More...
class  ExponentialRndGen
 exponential random generator More...
class  GaussianRndGen
 Gaussian random generator. More...
class  Geometric0RndGen
 Geometric random generator. More...
class  Geometric1RndGen
 Geometric random generator. More...
class  ParetoRndGen
 Pareto random generator. More...
class  WeibullRndGen
 Weibull random generator. More...
class  RayleighRndGen
 Rayleigh random generator. More...

Functions

void SetSeed (char *genType, int seed)
 Set the random generator type and the seed.
double rndUniformDouble (double low=0.0, double high=1.0)
 uniform double random generator
long int rndUniformInt (long int low=0, long int high=1)
 uniform long int random generator
double rndExponential (double M)
 exponential random generator
double rndGaussian (double M, double sigma)
 Gaussian random generator.
unsigned int rndGeometric0 (double M)
 Geometric random generator.
unsigned int rndGeometric1 (double M)
 Geometric random generator.
long int rndNegativeBinomial (long r, float p)
 Negative Binomial random generator.
double rndPareto (double location, double shape)
 Pareto random generator.
double rndWeibull (double location, double scale, double shape)
 Weibull random generator.
double rndRayleigh (double sigma)
 Rayleigh random generator.
void rndShuffle (void *vect, size_t size, size_t elem_size)
 Shuffle an array.

Function Documentation

double rndExponential double  M  ) 
 

exponential random generator

random generation of a double, exponentally distributed

Parameters:
M mean value of the exponential distribution
Returns:
a double

double rndGaussian double  M,
double  sigma
 

Gaussian random generator.

random generation of a double, following a Gaussian distribution

Parameters:
M mean value of the Gaussian distribution
sigma variance of the Gaussian distribution
Returns:
a double

unsigned int rndGeometric0 double  M  ) 
 

Geometric random generator.

random generation of an unsigned int, following a geometric distribution between 0 and infinity

Parameters:
M mean value of the geometric distribution
Returns:
an unsigned int

unsigned int rndGeometric1 double  M  ) 
 

Geometric random generator.

random generation of an unsigned int, following a geometric distribution between 1 and infinity

Parameters:
M mean value of the geometric distribution
Returns:
an unsigned int

long int rndNegativeBinomial long  r,
float  p
 

Negative Binomial random generator.

random generation of a long int, following a negative binomial distribution with PDF:

\[ p(x) = \left( \begin{array}{c} k + r -1 \\k \end{array} \right) p^r (1-p)^k \]

Parameters:
r refers to the above formula
p refers to the above formula
mean and variance of the negative binomial distribution are:

\[ E[x] = r \frac{1-p}{p} \qquad \qquad \qquad \sigma^2 = r \frac{1-p}{p^2} \]

Returns:
an unsigned int

double rndPareto double  location,
double  shape
 

Pareto random generator.

random generation of a double, following a Pareto distribution with PDF and CDF:

\[ p(x) = \frac{shape \, location^{shape}}{x^{shape+1}} \qquad \qquad \qquad P(x) = 1 - \left(\frac{location}{x}\right)^{shape} \]

Parameters:
location refers to the above formula
shape refers to the above formula
mean and variance of the Pareto distribution are:

\[ E[x] = \frac{location \, shape}{shape - 1} \qquad \qquad \qquad \sigma^2 = \frac{location^2 \, shape} { (shape -2) (shape - 1)^2 } \]

Returns:
a double

double rndRayleigh double  sigma  ) 
 

Rayleigh random generator.

random generation of a double, following a Rayleigh distribution with PDF and CDF:

\[ p(x) = \frac{x}{sigma^2} e^{-x^2/(2 sigma^2)} \qquad \qquad \qquad P(x) = 1 - e^{-x^2/(2 sigma^2)} \]

Parameters:
sigma refers to the above formula
mean and variance of the Rayleigh distribution are:

\[ E[x] = sigma \sqrt{\frac{\pi}{2}} \qquad \qquad \qquad \sigma^2 = sigma \frac{4-\pi}{2} \]

Returns:
a double

void rndShuffle void *  vect,
size_t  size,
size_t  elem_size
 

Shuffle an array.

This function randomly shuffles the order of elem_size objects, each of size size, stored in the array vect[0..n-1].

Parameters:
vect the array to be shuffled
size the size of each element of the array
elem_size the number of elements of the array

double rndUniformDouble double  low = 0.0,
double  high = 1.0
 

uniform double random generator

random generation of a double, uniformly distributed between [low, high)

Parameters:
low lower bound of the generation (inclusive)
high upper bound of the generation (exclusive)
Returns:
a double

long int rndUniformInt long int  low = 0,
long int  high = 1
 

uniform long int random generator

random generation of a long integer, uniformly distributed between [low, high]

Parameters:
low lower bound of the generation (inclusive)
high upper bound of the generation (inclusive)
Returns:
a long int

double rndWeibull double  location,
double  scale,
double  shape
 

Weibull random generator.

random generation of a double, following a Weibull distribution with PDF and CDF:

\[ p(x) = \frac{shape}{scale^{shape}} x^{shape-1} e^{-((x-location)/scale)^{shape}} \qquad \qquad \qquad P(x) = 1 - e^{-((x-location)/scale)^{shape}} \]

Parameters:
location refers to the above formula
scale refers to the above formula
shape refers to the above formula
mean and variance of the Weibull distribution are:

\[ E[x] = location + scale \, \Gamma\left(\frac{shape+1}{shape}\right) \qquad \qquad \qquad \sigma^2 = scale^2 \, ( \Gamma\left(\frac{shape+2}{shape}\right) - \Gamma^2\left(\frac{shape+1}{shape}\right) ) \]

Returns:
a double

void SetSeed char *  genType,
int  seed
 

Set the random generator type and the seed.

Parameters:
genType is the random generator type as specified by GSL constants;
seed is the seed of the generator.


Generated on Wed Dec 22 23:23:50 2004 for NePSing by doxygen 1.3.9.1 ---- Hosted by SourceForge.net Logo