VdCorput

Struct VdCorput 

Source
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: The count property 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 the pop() method is called.
  • base: The base property 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

Source

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: The base parameter 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.

Source

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);
Source

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.

Trait Implementations§

Source§

impl Debug for VdCorput

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.