Quality tested using PractRand
Randshow aims to be smoother in use and 'more random' that engines found in the <random> header of C++11. It ensures compatibility with UniformRandomBitGenerator
and C++11 <random> distributions.
Download the contents of the include directory and include desired headers in your code.
<randshow/engines.hpp>
- PCG with 64-bit state and 32-bit output as well as a variant with 128-bit state and 64-bit output.
- Xoshiro256++
- SplitMix64
- LCG
<randshow/distributions.hpp>
randshow::PCG32 rng(17) // Custom seed
uint32_t num = rng.Next() // Random 32-bit unsigned integer
uint32_t num_4_17 = rng.Next(4, 17); // Equivalent to creating a new std::uniform_int_distribution
double_t num_0_1 = rng.NextReal(); // Random number in (0.0, 1.0) range
// Create a histogram in Poisson distribution
randshow::PCG32 rng{};
std::unordered_map<int, int> counter{};
std::poisson_distribution<> dist{10};
for (int n = 1000; n--;) {
counter[dist(rng)] += 1;
}
for (size_t i = counter.size(); i--;) {
std::string count(counter[i], '*');
std::cout << i << ": " << count << "\n";
}
Licensed under the MIT license