Chebyshev
Unit testing for scientific software
chebyshev::random Namespace Reference

Pseudorandom number generation and sampling module. More...

Classes

class  random_settings
 Settings for the random module. More...
 

Functions

void setup (uint64_t seed=0)
 Initialize the random module.
 
uint64_t natural ()
 Generate a random natural number.
 
long double uniform (long double a, long double b)
 Generate a uniformly distributed random number. More...
 
template<typename Vector >
Vector & sample_uniform (Vector &x, const std::vector< prec::interval > intervals)
 Fill an already allocated vector with uniformly distributed numbers over different intervals. More...
 
long double gaussian (long double m, long double s)
 Generate a Gaussian distributed random number. More...
 
std::string string (size_t length)
 Generate a random string made of human-readable ASCII characters. More...
 
std::string string (size_t length, std::string alphabet)
 Generate a random string made of the elements of the given alphabet. More...
 
std::string string (size_t length, std::vector< char > alphabet)
 Generate a random string made of the elements of the given alphabet. More...
 
template<typename T >
std::vector< T > string (size_t length, std::vector< T > alphabet)
 Generate a random string made of the elements of the given alphabet, of arbitrary type. More...
 

Variables

struct chebyshev::random::random_settings settings
 

Detailed Description

Pseudorandom number generation and sampling module.

Function Documentation

◆ gaussian()

long double chebyshev::random::gaussian ( long double  m,
long double  s 
)
inline

Generate a Gaussian distributed random number.

Parameters
mThe mean of the distribution
sThe standard deviation of the distribution
Returns
A pseudorandom number Gaussian distributed.

◆ sample_uniform()

template<typename Vector >
Vector& chebyshev::random::sample_uniform ( Vector &  x,
const std::vector< prec::interval intervals 
)
inline

Fill an already allocated vector with uniformly distributed numbers over different intervals.

Parameters
xThe already initialized vector to fill.
intervalsThe intervals to generate over.
Returns
A reference to the overwritten vector.

◆ string() [1/4]

std::string chebyshev::random::string ( size_t  length)
inline

Generate a random string made of human-readable ASCII characters.

Parameters
lengthThe length of the string to generate
Returns
A string generated by choosing the elements of the alphabet with uniform probability.

◆ string() [2/4]

std::string chebyshev::random::string ( size_t  length,
std::string  alphabet 
)
inline

Generate a random string made of the elements of the given alphabet.

Parameters
lengthThe length of the string to generate
alphabetA string containing the elements of the alphabet.
Returns
A string generated by choosing the elements of the alphabet with uniform probability.

◆ string() [3/4]

std::string chebyshev::random::string ( size_t  length,
std::vector< char >  alphabet 
)
inline

Generate a random string made of the elements of the given alphabet.

Parameters
lengthThe length of the string to generate.
alphabetA vector containing the elements of the alphabet.
Returns
A string generated by choosing the elements of the alphabet with uniform probability.

◆ string() [4/4]

template<typename T >
std::vector<T> chebyshev::random::string ( size_t  length,
std::vector< T >  alphabet 
)
inline

Generate a random string made of the elements of the given alphabet, of arbitrary type.

Parameters
lengthThe length of the string to generate
Returns
A vector generated by choosing the elements of the alphabet with uniform probability.

◆ uniform()

long double chebyshev::random::uniform ( long double  a,
long double  b 
)
inline

Generate a uniformly distributed random number.

Parameters
aThe lower extreme of the interval
bThe upper extreme of the interval
Returns
A pseudorandom number uniformly distributed over (a, b).