pub struct Halton { /* private fields */ }Expand description
The Halton struct is a sequence generator that generates points in a 2-dimensional space using the
Halton sequence.
Properties:
vdc0: A variable of typeVdCorputthat represents the Van der Corput sequence generator for the first base. The Van der Corput sequence is a low-discrepancy sequence that is commonly used in quasi-Monte Carlo methods. It generates a sequence of numbers between 0 andvdc1: Thevdc1property is an instance of theVdCorputstruct, which is responsible for generating the Van der Corput sequence with a base of 3. The Van der Corput sequence is another low-discrepancy sequence commonly used in quasi-Monte Carlo methods
§Examples
use lds_rs::Halton;
let mut hgen = Halton::new(&[2, 3]);
hgen.reseed(10);
let result = hgen.pop();
assert_eq!(result[0], 0.8125);Implementations§
Source§impl Halton
impl Halton
Sourcepub fn new(base: &[usize]) -> Self
pub fn new(base: &[usize]) -> Self
The new function creates a new Halton object with specified bases for generating the Halton
sequence.
Arguments:
base: Thebaseparameter is an array of twousizevalues. These values are used as the bases for generating the Halton sequence. The first value in the array (base[0]) is used as the base for generating the first component of the Halton sequence, and the second
Returns:
The new function returns an instance of the Halton struct.
Sourcepub fn pop(&mut self) -> [f64; 2]
pub fn pop(&mut self) -> [f64; 2]
Returns the pop of this Halton.
The pop() function is used to generate the next value in the sequence.
For example, in the VdCorput class, pop() increments the count and
calculates the Van der Corput sequence value for that count and base. In
the Halton class, pop() returns the next point in the Halton sequence
as a [f64; 2]. Similarly, in the Circle class, pop()
returns the next point on the unit circle as a [f64; 2]. In
the Sphere class, pop() returns the next point on the unit sphere as a
[f64; 3]. And in the Sphere3Hopf class, pop() returns
the next point on the 3-sphere using the Hopf fibration as a
[f64; 4].
Returns:
An array of two f64 values is being returned.
§Examples
use lds_rs::lds::Halton;
let mut halton = Halton::new(&[2, 5]);
assert_eq!(halton.pop(), [0.5, 0.2]);Sourcepub fn reseed(&mut self, seed: usize)
pub fn reseed(&mut self, seed: usize)
The below code is a Rust function called reseed that is used to reset the state of a sequence
generator to a specific seed value. This allows the sequence generator to start generating the
sequence from the beginning or from a specific point in the sequence, depending on the value of the
seed.