pub struct VdCorput { /* private fields */ }Expand description
The VdCorput struct is a generator for the Van der Corput sequence, a low-discrepancy sequence
commonly used in quasi-Monte Carlo methods.
Properties:
count: Thecountproperty is used to keep track of the current iteration count of the Van der Corput sequence. It starts at 0 and increments by 1 each time thepop()method is called.base: Thebaseproperty represents the base of the Van der Corput sequence. It determines the number of digits used in each element of the sequence.
§Examples
use lds_rs::VdCorput;
let mut vgen = VdCorput::new(2);
vgen.reseed(10);
let result = vgen.pop();
assert_eq!(result, 0.8125);Implementations§
Source§impl VdCorput
impl VdCorput
Sourcepub fn new(base: usize) -> Self
pub fn new(base: usize) -> Self
The new function creates a new VdCorput object with a given base for generating the Van der
Corput sequence.
Arguments:
base: Thebaseparameter is an integer value that is used to generate the Van der Corput sequence. It determines the base of the sequence, which affects the distribution and pattern of the generated numbers.
Returns:
The new function returns a VdCorput object.
Sourcepub fn pop(&mut self) -> f64
pub fn pop(&mut self) -> f64
The pop function is a member function of the VdCorput class in Rust that increments the count
and calculates the next value in the Van der Corput sequence.
Returns:
The pop function returns a f64 value, which is the next value in the Van der Corput sequence.
§Examples
use lds_rs::lds::VdCorput;
let mut vd_corput = VdCorput::new(2);
assert_eq!(vd_corput.pop(), 0.5);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.