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

Aaron's random distribution functions. More...

Functions

template<typename Output_ = double, class Engine_ >
Output_ standard_uniform (Engine_ &eng)
 
template<typename Output_ = double, class Engine_ >
std::pair< Output_, Output_ > standard_normal (Engine_ &eng)
 
template<typename Output_ = double, class Engine_ >
Output_ standard_exponential (Engine_ &eng)
 
template<typename Output_ = int, class Engine_ >
Output_ discrete_uniform (Engine_ &eng, const Output_ bound)
 
template<class InputIterator_ , typename Length_ , class Engine_ >
void shuffle (const InputIterator_ values, const Length_ n, Engine_ &eng)
 
template<class InputIterator_ , typename Length_ , class OutputIterator_ , class Engine_ >
void sample (InputIterator_ values, const Length_ n, const Length_ s, OutputIterator_ output, Engine_ &eng)
 
template<typename Length_ , class OutputIterator_ , class Engine_ >
void sample (const Length_ bound, const Length_ s, OutputIterator_ output, Engine_ &eng)
 

Detailed Description

Aaron's random distribution functions.

Function Documentation

◆ discrete_uniform()

template<typename Output_ = int, class Engine_ >
Output_ aarand::discrete_uniform ( Engine_ & eng,
const Output_ bound )
Template Parameters
Output_Integer type of the output.
Engine_A 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<typename Length_ , class OutputIterator_ , class Engine_ >
void aarand::sample ( const Length_ bound,
const Length_ s,
OutputIterator_ output,
Engine_ & eng )
Template Parameters
Length_Integer type of the number of elements.
OutputIterator_Forward iterator or pointer for the outputs.
Engine_A 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 bound 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.

◆ sample() [2/2]

template<class InputIterator_ , typename Length_ , class OutputIterator_ , class Engine_ >
void aarand::sample ( InputIterator_ values,
const Length_ n,
const Length_ s,
OutputIterator_ output,
Engine_ & eng )
Template Parameters
InputIterator_Forward iterator or pointer for the inputs.
Length_Integer type of the number of elements.
OutputIterator_Forward iterator or pointer for the outputs.
Engine_A 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.

◆ shuffle()

template<class InputIterator_ , typename Length_ , class Engine_ >
void aarand::shuffle ( const InputIterator_ values,
const Length_ n,
Engine_ & eng )
Template Parameters
InputIterator_Random-access iterator or pointer.
Length_Integer type of the number of elements.
Engine_A 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 Output_ = double, class Engine_ >
Output_ aarand::standard_exponential ( Engine_ & eng)
Template Parameters
Output_Floating 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.
Engine_A 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. Values are guaranteed to be non-negative.

◆ standard_normal()

template<typename Output_ = double, class Engine_ >
std::pair< Output_, Output_ > aarand::standard_normal ( Engine_ & eng)
Template Parameters
Output_Floating point type of the output. 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.
Engine_A 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 Output_ = double, class Engine_ >
Output_ aarand::standard_uniform ( Engine_ & eng)
Template Parameters
Output_Floating point type of the output. 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.
Engine_A 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. All values are guaranteed to lie in [0, 1).