aarand
Aaron's random distribution functions
Loading...
Searching...
No Matches
Functions
aarand Namespace Reference

Namespace containing Aaron's random distribution functions. More...

Functions

template<typename T = double, class Engine >
standard_uniform (Engine &eng)
 
template<typename T = double, class Engine >
std::pair< T, Tstandard_normal (Engine &eng)
 
template<typename T = double, class Engine >
T standard_exponential (Engine &eng)
 
template<typename T = int, class Engine >
T discrete_uniform (Engine &eng, T bound)
 
template<class In , class Engine >
void shuffle (In values, size_t n, Engine &eng)
 
template<class In , class Out , class Engine >
void sample (In values, size_t n, size_t s, Out output, Engine &eng)
 
template<class Out , class Engine >
void sample (size_t bound, size_t s, Out output, Engine &eng)
 

Detailed Description

Namespace containing Aaron's random distribution functions.

Function Documentation

◆ discrete_uniform()

template<typename T = int, class Engine >
T aarand::discrete_uniform ( Engine eng,
T  bound 
)
Template Parameters
TInteger type.
EngineA random number generator class with operator(), min() (static) and max() (static) methods, where the result_type is an unsigned integer value.
Parameters
engInstance of an RNG class like std::mt19937_64.
boundPositive integer specifying the upper bound of the discrete distribution.
Returns
Draw from a discrete uniform distribution in [0, bound).

◆ sample() [1/2]

template<class In , class Out , class Engine >
void aarand::sample ( In  values,
size_t  n,
size_t  s,
Out  output,
Engine eng 
)
Template Parameters
InRandom-access iterator or pointer for the inputs.
OutRandom-access iterator or pointer for the outputs.
EngineA random number generator class with operator(), min() (static) and max() (static) methods, where the result_type is an unsigned integer value.
Parameters
[in]valuesIterator or pointer to an array of values to sample from.
nNumber of values in the array pointed to by values.
sNumber of values to sample.
[out]outputIterator or pointer to an array of length s, to store the sampled values. On return, output is filled with s sampled values from values. If s > n, values is copied into the first n elements of output and the remaining values of output are undefined.
engInstance of an RNG class like std::mt19937_64.

◆ sample() [2/2]

template<class Out , class Engine >
void aarand::sample ( size_t  bound,
size_t  s,
Out  output,
Engine eng 
)
Template Parameters
OutRandom-access iterator or pointer for the outputs.
EngineA random number generator class with operator(), min() (static) and max() (static) methods, where the result_type is an unsigned integer value.
Parameters
boundUpper bound of the indices to sample from.
sNumber of values to sample.
[out]outputIterator or pointer to an array of length s, to store the sampled values. output is filled with s sampled values from the sequence of integers in {0, 1, ..., bound - 1}. If s > bound, the first n elements of output will contain the sequence of integers from 0 to bound - 1. The remaining values of output are undefined.
engInstance of an RNG class like std::mt19937_64.

◆ shuffle()

template<class In , class Engine >
void aarand::shuffle ( In  values,
size_t  n,
Engine eng 
)
Template Parameters
InRandom-access iterator or pointer.
EngineA random number generator class with operator(), min() (static) and max() (static) methods, where the result_type is an unsigned integer value.
Parameters
[in,out]valuesIterator or pointer to an array of values to shuffle. On return, contents of values are randomly permuted in place using the Fisher-Yates algorithm.
nNumber of values in the array pointed to by values.
engInstance of an RNG class like std::mt19937_64.

◆ standard_exponential()

template<typename T = double, class Engine >
T aarand::standard_exponential ( Engine eng)
Template Parameters
TFloating point type to return. This is also used for intermediate calculations, so it is usually safest to provide a type that is at least as precise as a double.
EngineA random number generator class with operator(), min() (static) and max() (static) methods, where the result_type is an unsigned integer value.
Parameters
engInstance of an RNG class like std::mt19937_64.
Returns
Draw from a standard exponential distribution.

◆ standard_normal()

template<typename T = double, class Engine >
std::pair< T, T > aarand::standard_normal ( Engine eng)
Template Parameters
TFloating point type to return. This is also used for intermediate calculations, so it is usually safest to provide a type that is at least as precise as a double.
EngineA random number generator class with operator(), min() (static) and max() (static) methods, where the result_type is an unsigned integer value.
Parameters
engInstance of an RNG class like std::mt19937_64.
Returns
A pair of independent draws from a standard normal distribution with mean 0 and variance 1.

◆ standard_uniform()

template<typename T = double, class Engine >
T aarand::standard_uniform ( Engine &  eng)
Template Parameters
TFloating point type to return. This is also used for intermediate calculations, so it is usually safest to provide a type that is at least as precise as a double.
EngineA random number generator class with operator(), min() (static) and max() (static) methods, where the result_type is an unsigned integer value.
Parameters
engInstance of an RNG class like std::mt19937_64.
Returns
Draw from a standard uniform distribution.