A simple quasi-random number generator implementation in C++ for generating low-discrepancy sequences.
It generates points on a unit hypercube in any number of dimensions.
Based on:
Martin Roberts, 2018. "The Unreasonable Effectiveness of Quasirandom Sequences"
#include "quasirand.hpp"
using namespace quasirand;
int main()
{
/* Initialize a generator in 3 dimensions. */
QuasiRandom qrng(3);
/* Generate the next point of the sequence. */
vector<double> point = qrng();
/* Generate the 500th point of the sequence. */
vector<double> point500 = qrng(500);
/* Discard the next point from the sequence. */
qrng.discard();
/* Set a seed different from the default one. */
qrng.reset(0.13);
}
The dimension of the generator can also be chosen at compile time:
#include "quasirand.hpp"
using namespace quasirand;
int main()
{
/* Initialize a generator in 3 dimensions. */
QuasiRandom<3> qrng;
/* Generate the next point of the sequence. */
array<double, 3> point = qrng();
}