Expand description
Low-Discrepancy Sequence (LDS) Generator
This library implements a set of low-discrepancy sequence generators, which are used to create sequences of numbers that are more evenly distributed than random numbers. These sequences are particularly useful in various fields such as computer graphics, numerical integration, and Monte Carlo simulations.
The library defines several structs, each representing a different type of low-discrepancy sequence generator. The main types of sequences implemented are:
- van der Corput sequence
- Halton sequence
- Circle sequence
- Disk sequence
- Sphere sequence
- 3-Sphere Hopf sequence
- N-dimensional Halton sequence
Each generator takes specific inputs, usually in the form of base numbers or sequences of base numbers. These bases determine how the sequences are generated. The generators produce outputs in the form of floating-point numbers or vectors of floating-point numbers, depending on the dimensionality of the sequence.
The core algorithm used in most of these generators is the van der Corput sequence. This sequence is created by expressing integers in a given base, reversing the digits, and placing them after a decimal point. For example, in base 2, the sequence would start: 1/2, 1/4, 3/4, 1/8, 5/8, and so on.
The Halton sequence extends this concept to multiple dimensions by using a different base for each dimension. The Circle and Sphere sequences use trigonometric functions to map these low-discrepancy sequences onto circular or spherical surfaces.
The library also includes utility functions and constants to support these generators. For instance, there’s a list of prime numbers that can be used as bases for the sequences.
Each generator struct has methods to produce the next value in the sequence (pop()) and to reset the sequence to a specific starting point (reseed()). This allows for flexible use of the generators in various applications.
The purpose of this library is to provide a toolkit for generating well-distributed sequences of numbers, which can be used in place of random numbers in many applications to achieve more uniform coverage of a given space or surface. This can lead to more efficient and accurate results in tasks like sampling, integration, and optimization.
Figure: 500 points of a 2D Halton sequence with bases 2 and 3.
The image above is embedded via embed-doc-image. To build docs with images locally:
cargo doc --features doc-images --openOn docs.rs, images are rendered automatically.
§Visual examples
| Generator | Visualisation |
|---|---|
| Van der Corput (base 2) — 64 values | |
| Circle (base 2) — 200 points | |
| Disk (bases 2, 3) — 200 points | |
| Halton 2D (bases 2, 3) — 500 points |
Modules§
- ilds
- Integer low-discrepancy sequence generators Integer Low-Discrepancy Sequence (ILDS) Generator
- sphere_
n - N-dimensional sphere sequence generators Generates points on n-dimensional spheres.
Structs§
- Circle
- Unit Circle sequence generator
- Disk
- Unit Disk sequence generator
- Halton
- Halton sequence generator
- HaltonN
- N-dimensional Halton sequence generator
- Sphere
- Unit Sphere sequence generator
- Sphere3
Hopf - Sphere-3 sequence generator using Hopf coordinates
- VdCorput
- van der Corput sequence generator
Constants§
- MAX_
DIGITS - Maximum number of digits for van der Corput sequence
- PRIME_
TABLE - First 1000 prime numbers
- TWO_PI
- Constant for 2π
Functions§
- vdc
- van der Corput sequence function