https://github.com/artichoke/rand_mt
🌪 Mersenne Twister implementation backed by rand_core
https://github.com/artichoke/rand_mt
artichoke mersenne-twister no-std rand random rng rust rust-crate
Last synced: 5 months ago
JSON representation
🌪 Mersenne Twister implementation backed by rand_core
- Host: GitHub
- URL: https://github.com/artichoke/rand_mt
- Owner: artichoke
- License: apache-2.0
- Created: 2020-03-14T23:18:59.000Z (over 6 years ago)
- Default Branch: trunk
- Last Pushed: 2025-04-08T00:06:34.000Z (about 1 year ago)
- Last Synced: 2025-04-10T01:09:35.839Z (about 1 year ago)
- Topics: artichoke, mersenne-twister, no-std, rand, random, rng, rust, rust-crate
- Language: Rust
- Homepage: https://crates.io/crates/rand_mt
- Size: 2.31 MB
- Stars: 13
- Watchers: 5
- Forks: 6
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# rand_mt
[](https://github.com/artichoke/rand_mt/actions)
[](https://codecov.artichokeruby.org/rand_mt/index.html)
[](https://twitter.com/artichokeruby)
[](https://crates.io/crates/rand_mt)
[](https://docs.rs/rand_mt)
[](https://artichoke.github.io/rand_mt/rand_mt/)
Implements a selection of Mersenne Twister random number generators.
> A very fast random number generator of period 219937-1. (Makoto
> Matsumoto, 1997).
The Mersenne Twister algorithms are not suitable for cryptographic uses, but are
ubiquitous. See the [Mersenne Twister website]. A variant of Mersenne Twister is
the [default PRNG in Ruby].
[mersenne twister website]:
http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
[default prng in ruby]: https://ruby-doc.org/core-3.1.2/Random.html
This crate optionally depends on [`rand_core`] and implements `Rng` on the RNGs
in this crate.
[`rand_core`]: https://crates.io/crates/rand_core
## Usage
Add this to your `Cargo.toml`:
```toml
[dependencies]
rand_mt = "6.0.0"
```
Then create a RNG like:
```rust
use rand_mt::Mt64;
let mut rng = Mt64::new_unseeded();
assert_ne!(rng.next_u64(), rng.next_u64());
```
## Crate Features
`rand_mt` is `no_std` compatible. `rand_mt` has several optional features that
are enabled by default:
- **rand-traits** - Enables a dependency on [`rand_core`]. Activating this
feature implements `Rng` and `SeedableRng` on the RNGs in this crate.
Mersenne Twister requires approximately 2.5 kilobytes of internal state. To make
the RNGs implemented in this crate practical to embed in other structs, you may
wish to store the RNG in a `Box`.
### Minimum Supported Rust Version
This crate requires at least Rust 1.85.0. This version can be bumped in minor
releases.
## License
`rand_mt` is distributed under the terms of either the
[MIT License](LICENSE-MIT) or the
[Apache License (Version 2.0)](LICENSE-APACHE).
`rand_mt` is derived from `rust-mersenne-twister` @ [`1.1.1`] which is Copyright
(c) 2015 rust-mersenne-twister developers.
[`1.1.1`]: https://github.com/dcrewi/rust-mersenne-twister/tree/1.1.1