Skip to content

Latest commit

 

History

History
65 lines (46 loc) · 1.66 KB

README.md

File metadata and controls

65 lines (46 loc) · 1.66 KB

Quasi-random number generator

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"

Usage

#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);
}

Static generator dimensions

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();
}

Examples of generated sequences

2-dimensions

3-dimensions