4 releases

0.1.3 Aug 9, 2019
0.1.2 Aug 9, 2019
0.1.1 Aug 9, 2019
0.1.0 Aug 9, 2019

#3 in #middle

ISC license

6KB
92 lines

Middle Square Weyl Sequence RNG for Rust

travis license version documentation

A new implementation of John von Neumann's middle square random number generator (RNG). A Weyl sequence is utilized to keep the generator running through a long period.

Paper

Using

This library includes a few thread-safe functions.

weyl::u64()            // generates a random u64
weyl::f64()            // generates a random f64
weyl::fill(&mut bytes) // fill byte slice with random data
weyl::seed(my_seed)    // reseed the number generator

There's also a Generator type in case you need to generate random numbers in an isolated thread. It's little faster because it avoids mutex locks.

let mut rand = weyl::Generator::new(my_seed);
println!("{}", rand.u64());             // generates a random u64

Contact

Josh Baker @tidwall

License

Weyl source code is available under the ISC License.

Dependencies

~11KB