#halton-sequence

no-std halton

A module for generating Halton sequences

3 unstable releases

0.2.1 Dec 6, 2019
0.2.0 Dec 5, 2019
0.1.0 Apr 15, 2018

#840 in Algorithms

Download history 8/week @ 2022-10-08 5/week @ 2022-10-15 6/week @ 2022-10-22 11/week @ 2022-10-29 17/week @ 2022-11-05 7/week @ 2022-11-12 10/week @ 2022-11-19 6/week @ 2022-11-26 11/week @ 2022-12-03 85/week @ 2022-12-10 11/week @ 2022-12-17 39/week @ 2022-12-24 9/week @ 2022-12-31 9/week @ 2023-01-07 13/week @ 2023-01-14 19/week @ 2023-01-21

52 downloads per month
Used in warped-sampling

MIT/Apache

14KB
257 lines

halton

Build Version Docs

A module for generating Halton sequences, a deterministic low discrepancy sequence that appears to be random. The uniform distribution and repeatability makes the sequence ideal for choosing sample points or placing objects in 2D or 3D space.

Examples

use halton::Sequence;

let mut grid = [["."; 10]; 10];
let alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("").skip(1).take(26);
let seq = Sequence::new(2).zip(Sequence::new(3)).zip(alpha);
for ((x, y), c) in seq {
    grid[(y * 10.0) as usize][(x * 10.0) as usize] = c;
}
for row in grid.iter() {
    println!("{}", row.join(" "));
}

Outputs:

. . R . . I . . . .
. L . . . . U C . .
X . . F . . . . . O
. . . J . A . . . .
. D . . . . M S . .
P . . . V . . . G .
. . B . . Y . . . .
. T . . . . E . K .
H . . . N . . . . W
. . . Z . Q . . . .

License

This project is licensed under either of

at your option.

No runtime deps