Aaron's random distribution functions.
More...
|
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) |
|
Aaron's random distribution functions.
◆ 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
-
eng | Instance of an RNG class like std::mt19937_64 . |
bound | Positive 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
-
| bound | Upper bound of the indices to sample from. |
| s | Number of values to sample. |
[out] | output | Iterator 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. |
| eng | Instance 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] | values | Iterator or pointer to an array of values to sample from. |
| n | Number of values in the array pointed to by values . |
| s | Number of values to sample. |
[out] | output | Iterator 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. |
| eng | Instance 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] | values | Iterator or pointer to an array of values to shuffle. On return, contents of values are randomly permuted in place using the Fisher-Yates algorithm. |
| n | Number of values in the array pointed to by values . |
| eng | Instance 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
-
eng | Instance 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
-
eng | Instance 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
-
eng | Instance of an RNG class like std::mt19937_64 . |
- Returns
- Draw from a standard uniform distribution. All values are guaranteed to lie in
[0, 1)
.