Crates.io | sobol_burley |
lib.rs | sobol_burley |
version | 0.5.0 |
source | src |
created_at | 2021-05-11 20:22:36.052074 |
updated_at | 2023-07-05 09:30:09.770301 |
description | A seedable Owen-scrambled Sobol sequence. |
homepage | |
repository | https://github.com/cessen/sobol_burley |
max_upload_size | |
id | 396275 |
size | 76,882 |
A seedable Owen-scrambled Sobol sequence based on the paper Practical Hash-based Owen Scrambling by Brent Burley, but with an improved hash from Building a Better LK Hash and more dimensions due to Kuo et al.
This crate is geared towards practical graphics applications, and as such has some limitations:
f32
output is supported.These are all trade-offs for the sake of better performance and a smaller memory footprint.
Expanding this crate to be more suitable for a wider range of applications is a tentative goal for the future. However, efficient execution for graphics applications will always be the top priority.
Basic usage is pretty straightforward:
use sobol_burley::sample;
// Print 1024 3-dimensional points.
for i in 0..1024 {
let x = sample(i, 0, 0);
let y = sample(i, 1, 0);
let z = sample(i, 2, 0);
println!("({}, {}, {})", x, y, z);
}
The first parameter of sample()
is the index of the sample you want, and the second parameter is the index of the dimension you want. The parameters are zero-indexed, and outputs are in the interval [0, 1).
If all you want is a single Owen-scrambled Sobol sequence, then this is all you need. For more advanced usage, see the crate documentation.
There are other resources that explain this properly and in-depth, including Brent Burley's paper linked above. But here's the short version just to give some intuition:
If you use random points, you get this:
If you use plain Sobol, you get this:
But if you use Owen-scrambled Sobol, you get this:
Random points have an uneven distribution, and plain Sobol exhibits a strong structure that can result in bias and artifacts. But Owen-scrambled Sobol in some sense gets the best of both worlds: the even distribution of Sobol, but randomized to minimize structure.
This crate uses unsafe code for SIMD acceleration. For 100% safe code, you can disable SIMD support via the simd
feature flag (enabled by default).
The main code in this project is licensed under either of
at your option.
The Sobol direction numbers under direction_numbers/
and some of the code in build.rs
(demarcated by comments) is adapted from work by Stephen Joe and Frances Y. Kuo, and is under the 3-clause BSD license. See licenses/JOE_KUO.txt
for details.
Contributions are absolutely welcome! Please keep in mind that this crate aims to be:
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you will be licensed as above (MIT/Apache dual-license), without any additional terms or conditions.