Sampling Functions

Sampling Functions #

Random Number Generation #

File position: /EMOC/vendor/random.h and /EMOC/vendor/random.cpp

Random number generation is a basic function for evolutionary algorithm, EMOC provides several random number related functions as below:

double randomperc()

Fetch a single random number between 0.0 and 1.0.

Parameter:
void
Returns:
rand: double
    A random number between 0.0 and 1.0.
int rnd(int low, int high)

Return a random integer between low and high.

Parameter:
low: int, default=None
    Lower boundary of random integer.

high: int, default=None
    Upper boundary of random integer.
Returns:
rand: double
    A random integer between low and high.
double rndreal(double low, double high)

Return a random real number between low and high.

Parameter:
low: double, default=None
    Lower boundary of random double.

high: double, default=None
    Upper boundary of random double.
Returns:
rand: double
    A random double between low and high.

Sampling from Distribution #

File position: /EMOC/src/core/utility.h and /EMOC/src/core/utility.cpp

There are also some sampling function for different distribution:

double CauchyRandom(double location, double scale)

Return a sample value subject to Cauchy distribution.

Parameter:
location: double, default=None
    The location parameter of Cauchy distribution.

scale: double, default=None
    The scale parameter of Cauchy distribution.
Returns:
sample: double
    A random sample from Cauchy distribution.
double BetaRandom(double a, double b)

Return a sample value subject to Beta distribution.

Parameter:
a: double, default=None
    The alpha parameter of Beta distribution.

b: double, default=None
    The beta parameter of Beta distribution.
Returns:
sample: double
    A random sample from Beta distribution.
double GaussianRandom(double mean, double stdev)

Return a sample value subject to Gaussian distribution.

Parameter:
mean: double, default=None
    The mean parameter of Gaussian distribution.

stdev: double, default=None
    The standard deviation parameter of Gaussian distribution.
Returns:
sample: double
    A random sample from Gaussian distribution.