#statistics #quasirandom

quasi-rd

Generate quasirandom Rd sequences

1 unstable release

0.1.0 Dec 20, 2019

#217 in #statistics

MIT license

42KB
321 lines

quasi-rd

Documentation Crates.io

An implementation of the quasirandom Rd sequence described in this blog post. This sequence may not necessarily be optimal for all dimensionalities or all applications but it has the advantage of working quite well in general, being very fast to generate and also being parameter-free as all the parameters are fixed and thus do not require application-specific configuration.

This implementation does not use floating-point arithmetic to compute the sequence but uses a 128-bit fixed-point representation, only converting to floating-point as a final step if required. As a result it produces exact sequences of up to 2^64 samples, which should be enough for almost every application. Parameters for up to 1M-dimensional sequences are computed to within 128 bits of accuracy using rational arithmetic.

Usage

This code generates quasirandomly distributed points in two dimensions:

use quasi_rd::Sequence;

let mut sequence = Sequence::new(2);

for _ in 0..500 {
    println!("({}, {})", sequence.next_f64(), sequence.next_f64());
}

Plotting these points will produce a distribution like this:

License

This crate is licensed under the terms of the MIT license. See LICENSE.md for more information.

Dependencies

~605KB
~14K SLoC