Skip to content

A simple quasi-random number generator implemented in C++ for generating low discrepancy sequences in any number of dimensions.

License

Notifications You must be signed in to change notification settings

KRM7/quasi-random

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A simple quasi-random number generator implemented in C++ for generating low discrepancy sequences in any number of dimensions.

Topics

Resources

License

Stars

Watchers

Forks