|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file.
55 return x >> r | x << (-r & 31);
61 auto count =
static_cast<unsigned int>( x >> 59 );
65 return pcg32_rotr32(
static_cast<uint32_t
>( x >> 27 ), count );
76 throw std::invalid_argument(
77 "Invalid call to permuted_congruential_generator( " +
std::to_string(min) +
", " +
91 if( chance_one_in == 0 ) {
92 throw std::invalid_argument(
93 "Invalid call to permuted_congruential_generator_bool( 0 )"
113 std::vector<size_t> result;
117 throw std::invalid_argument(
118 "Cannot select more unique elements than there are elements: k == " +
124 std::uniform_real_distribution<double> distribution( 0.0, 1.0 );
131 double const u = distribution( engine );
133 if( (n - t) * u >= k - m ) {
137 result.push_back( t );
143 assert( result.size() == k );
void permuted_congruential_generator_init(uint64_t seed)
Set the seed for permuted_congruential_generator().
static uint32_t pcg32_rotr32(uint32_t x, unsigned int r)
std::string to_string(GenomeLocus const &locus)
static uint64_t pcg32_state
bool permuted_congruential_generator_bool()
Fast random number generator for 32bit integers, for bool with 0.5 probability.
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
std::default_random_engine & random_engine()
Return a thread-local engine for random number generation.
static const uint64_t pcg32_increment
std::vector< size_t > select_without_replacement(size_t const k, size_t const n)
Select k many unique numbers out of the range [ 0, n ).
static Options & get()
Returns a single instance of this class.
uint32_t permuted_congruential_generator()
Fast random number generator for 32bit integers.
static const uint64_t pcg32_multiplier