ModErn Text Analysis
META Enumerates Textual Applications

A collection of utility classes/functions for randomness. More...
Classes  
class  any_rng 
A class to typeerase any unsigned random number generator in a way that makes STL algorithms happy. More...  
Functions  
template<class RandomEngine >  
RandomEngine::result_type  bounded_rand (RandomEngine &rng, typename RandomEngine::result_type upper_bound) 
Generate a random number between 0 and an (exclusive) upper bound. More...  
template<class RandomAccessIterator , class RandomEngine >  
void  shuffle (RandomAccessIterator first, RandomAccessIterator last, RandomEngine &&rng) 
Shuffles the given range using the provided rng. More...  
A collection of utility classes/functions for randomness.
(e.g. random number generation, shuffling, etc.).
RandomEngine::result_type meta::random::bounded_rand  (  RandomEngine &  rng, 
typename RandomEngine::result_type  upper_bound  
) 
Generate a random number between 0 and an (exclusive) upper bound.
This uses the rejection sampling technique, and it assumes that the RandomEngine has a strictly larger range than the desired one.
rng  The rng to generate numbers from 
upper_bound  The exclusive upper bound for the number 
void meta::random::shuffle  (  RandomAccessIterator  first, 
RandomAccessIterator  last,  
RandomEngine &&  rng  
) 
Shuffles the given range using the provided rng.
THERE IS A REASON we don't use std::shuffle here: we want reproducibility between compilers, who don't seem to agree on the number of times to call rng_ in the shuffle process.
Furthermore, it seems that we can't rely on a canonical number of rng_ calls in std::uniform_int_distribution, either, so that's out too.
We instead use random::bounded_rand(), since we know that the range of the RNG is definitely going to be larger than the upper bounds we request here.
first  The iterator to the beginning of the range to be shuffled 
last  The iterator to the end of the range to be shuffled 
rng  The random number generator to use 