Autopysta
Loading...
Searching...
No Matches
random_generator Class Reference

Utility class for generating random numbers. More...

#include <random_generator.h>

Static Public Member Functions

static void init ()
 Initialize the random number generator with a seed.
 
static double uniform (double a, double b)
 Generate a random value from a uniform distribution [a, b].
 
static double uniform01 ()
 Generate a random value from a standard uniform distribution [0, 1].
 
static double logistic (double mu, double s)
 Generate a random value from a logistic distribution.
 
static double normal (double mu, double sigma)
 Generate a random value from a normal (Gaussian) distribution.
 

Detailed Description

Utility class for generating random numbers.

The random_generator class provides static methods to generate random values from different probability distributions. These include the uniform, standard uniform, logistic, and normal distributions. The class uses a Mersenne Twister pseudo-random generator.

Member Function Documentation

◆ init()

static void random_generator::init ( )
static

Initialize the random number generator with a seed.

This method initializes the Mersenne Twister generator using the current time as the seed. This ensures that the generator produces different random sequences each time the program runs.

◆ logistic()

static double random_generator::logistic ( double mu,
double s )
static

Generate a random value from a logistic distribution.

This method returns a random value sampled from a logistic distribution with location mu and scale s. The logistic distribution is commonly used in various models, including machine learning and statistics.

Parameters
muThe location parameter of the logistic distribution (mean).
sThe scale parameter (related to the standard deviation).
Returns
A random double value sampled from a logistic distribution.

◆ normal()

static double random_generator::normal ( double mu,
double sigma )
static

Generate a random value from a normal (Gaussian) distribution.

This method returns a random value sampled from a normal distribution with mean mu and standard deviation sigma.

Parameters
muThe mean of the normal distribution.
sigmaThe standard deviation of the normal distribution.
Returns
A random double value sampled from a normal distribution.

◆ uniform()

static double random_generator::uniform ( double a,
double b )
static

Generate a random value from a uniform distribution [a, b].

This method returns a random value sampled from a uniform distribution with bounds a and b.

Parameters
aThe minimum value of the distribution.
bThe maximum value of the distribution.
Returns
A random double value between a and b.

◆ uniform01()

static double random_generator::uniform01 ( )
static

Generate a random value from a standard uniform distribution [0, 1].

This method returns a random value sampled from a uniform distribution between 0 and 1.

Returns
A random double value between 0 and 1.

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