Weyl sequence


In mathematics, a Weyl sequence is a sequence from the equidistribution theorem proven by Hermann Weyl:
The sequence of all multiples of an irrational α,
In other words, the sequence of the fractional parts of each term will be uniformly distributed in the interval 0, 1).

In [computing

In computing, an integer version of this sequence is often used to generate a discrete uniform distribution rather than a continuous one. Instead of using an irrational number, which cannot be calculated on a digital computer, the ratio of two integers is used in its place. An integer k is chosen, relatively prime to an integer modulus m. In the common case that m is a power of 2, this amounts to requiring that k is odd.
The sequence of all multiples of such an integer k,
That is, the sequence of the remainders of each term when divided by m will be uniformly distributed in the interval .
The following C code generates what Marsaglia calls a "Weyl sequence":
In this case, the odd integer is 362437, and the results are computed modulo because d is a 32-bit quantity. The results are equidistributed modulo 232.