Because any distribution of random numbers can be mapped onto a uniform distribution, and quasirandom numbers are mapped in the same way, this article only concerns generation of quasirandom numbers on a multidimensional uniform distribution. There are constructions of sequences known such that D_N^{*}(x_1,\ldots,x_N)\leq C\frac{(\ln N)^{s}}{N}. where C is a certain constant, depending on the sequence. After Conjecture 2, these sequences are believed to have the best possible order of convergence. Examples below are the
van der Corput sequence, the
Halton sequences, and the
Sobol’ sequences. One general limitation is that construction methods can usually only guarantee the order of convergence. Practically, low discrepancy can be only achieved if N is large enough, and for large given s this minimum N can be very large. This means running a Monte-Carlo analysis with e.g. s=20 variables and N=1000 points from a low-discrepancy sequence generator may offer only a very minor accuracy improvement .
Random numbers Sequences of quasirandom numbers can be generated from random numbers by imposing a negative correlation on those random numbers. One way to do this is to start with a set of random numbers r_i on [0,0.5) and construct quasirandom numbers s_i which are uniform on [0,1) using: s_i = r_i for i odd and s_i = 0.5 + r_i for i even. A second way to do it with the starting random numbers is to construct a random walk with offset 0.5 as in: s_i = s_{i-1} + 0.5+ r_i \pmod 1. \, That is, take the previous quasirandom number, add 0.5 and the random number, and take the result
modulo 1. For more than one dimension,
Latin squares of the appropriate dimension can be used to provide offsets to ensure that the whole domain is covered evenly.
Additive recurrence For any irrational \alpha, the sequence s_n = \{s_0 + n\alpha\} has discrepancy tending to 1/N. Note that the sequence can be defined recursively by s_{n+1} = (s_n + \alpha)\bmod 1 \;. A good value of \alpha gives lower discrepancy than a sequence of independent uniform random numbers. The discrepancy can be bounded by the
approximation exponent of \alpha. If the approximation exponent is \mu, then for any \varepsilon>0, the following bound holds: D_N((s_n)) = O_\varepsilon (N^{-1/(\mu-1)+\varepsilon}). By the
Thue–Siegel–Roth theorem, the approximation exponent of any irrational
algebraic number is 2, giving a bound of N^{-1+\varepsilon} above. The recurrence relation above is similar to the recurrence relation used by a
linear congruential generator, a poor-quality pseudorandom number generator: r_i = (a r_{i-1} + c) \bmod m For the low discrepancy additive recurrence above,
a and
m are chosen to be 1. Note, however, that this will not generate independent random numbers, so should not be used for purposes requiring independence. The value of c with lowest discrepancy is the
fractional part of the
golden ratio: c = \frac{\sqrt{5}-1}{2} = \varphi - 1 \approx 0.618034. Another value that is nearly as good is the fractional part of the
silver ratio, which is the fractional part of the square root of 2: c = \sqrt{2}-1 \approx 0.414214. \, In more than one dimension, separate quasirandom numbers are needed for each dimension. A convenient set of values that are used, is the square roots of
primes from two up, all taken modulo 1: c = \sqrt{2}, \sqrt{3}, \sqrt{5}, \sqrt{7}, \sqrt{11}, \ldots \, However, a set of values based on the generalised golden ratio has been shown to produce more evenly distributed points. The
list of pseudorandom number generators lists methods for generating independent pseudorandom numbers.
Note: In few dimensions, recursive recurrence leads to uniform sets of good quality, but for larger s (like s>8 ) other point set generators can offer much lower discrepancies.
van der Corput sequence Let n=\sum_{k=0}^{L-1}d_k(n)b^k be the b-ary representation of the positive integer n \geq 1, i.e. 0 \leq d_k(n) . Set g_b(n)=\sum_{k=0}^{L-1}d_k(n)b^{-k-1}. Then there is a constant C depending only on b such that (g_b(n))_{n \geq 1} satisfies D^*_N(g_b(1),\dots,g_b(N))\leq C\frac{\log N}{N}, where D^*_N is the
star discrepancy.
Halton sequence The Halton sequence is a natural generalization of the van der Corput sequence to higher dimensions. Let
s be an arbitrary dimension and
b1, ...,
bs be arbitrary
coprime integers greater than 1. Define x(n)=(g_{b_1}(n),\dots,g_{b_s}(n)). Then there is a constant
C depending only on
b1, ...,
bs, such that sequence {
x(
n)}
n≥1 is a
s-dimensional sequence with D^*_N(x(1),\dots,x(N))\leq C'\frac{(\log N)^s}{N}.
Hammersley set Let b_1,\ldots,b_{s-1} be
coprime positive integers greater than 1. For given s and N, the s-dimensional
Hammersley set of size N is defined by x(n)=\left(g_{b_1}(n),\dots,g_{b_{s-1}}(n),\frac{n}{N}\right) for n = 1, \ldots, N. Then D^*_N(x(1),\dots,x(N))\leq C\frac{(\log N)^{s-1}}{N} where C is a constant depending only on b_1, \ldots, b_{s-1}.
Note: The formulas show that the Hammersley set is actually the Halton sequence, but we get one more dimension for free by adding a linear sweep. This is only possible if N is known upfront. A linear set is also the set with lowest possible one-dimensional discrepancy in general. Unfortunately, for higher dimensions, no such "discrepancy record sets" are known. For s=2, most low-discrepancy point set generators deliver at least near-optimum discrepancies.
Sobol sequence The Antonov–Saleev variant of the Sobol’ sequence generates numbers between zero and one directly as binary fractions of length w, from a set of w special binary fractions, V_i, i = 1, 2, \dots, w called direction numbers. The bits of the
Gray code of i, G(i), are used to select direction numbers. To get the Sobol’ sequence value s_i take the
exclusive or of the binary value of the Gray code of i with the appropriate direction number. The number of dimensions required affects the choice of V_i.
Poisson disk sampling Poisson disk sampling is popular in video games to rapidly place objects in a way that appears random-looking but guarantees that every two points are separated by at least the specified minimum distance. This does not guarantee low discrepancy (as e. g. Sobol’), but at least a significantly lower discrepancy than pure random sampling. The goal of these sampling patterns is based on
frequency analysis rather than discrepancy, a type of so-called "blue noise" patterns. ==Graphical examples==