https://github.com/matsadler/halton-rb
A Ruby library, written in Rust, for generating Halton sequences
https://github.com/matsadler/halton-rb
halton-sequence ruby rust
Last synced: about 1 year ago
JSON representation
A Ruby library, written in Rust, for generating Halton sequences
- Host: GitHub
- URL: https://github.com/matsadler/halton-rb
- Owner: matsadler
- License: mit
- Created: 2021-05-03T05:39:32.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2023-08-11T04:35:50.000Z (almost 3 years ago)
- Last Synced: 2025-03-25T19:04:30.780Z (about 1 year ago)
- Topics: halton-sequence, ruby, rust
- Language: Ruby
- Homepage:
- Size: 33.2 KB
- Stars: 10
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rdoc
- License: LICENSE
Awesome Lists containing this project
README
= Halton
A Ruby library for the fast generation of 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.
grid = 10.times.map {10.times.map {"."}}
Halton.each(2, 3).take(26).zip("A".."Z") do |(x, y), c|
grid[y * 10][x * 10] = c
end
grid.each {|row| puts 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 . . . .
The method of generation is adapted from "Fast, portable, and reliable
algorithm for the calculation of Halton numbers" by Miroslav Kolář and Seamus F.
O'Shea.
== Install
Install via Rubygems:
gem install halton
or add it to your Gemfile if you're using Bundler:
gem "halton"
and then run the bundle command to install.
This gem requires a Rust compiler and the +cargo+ build tool to build the gem's
native extension. See https://www.rust-lang.org/tools/install for how to
install Rust. +cargo+ is usually part of the Rust installation.