1 unstable release

new 0.1.0 Mar 27, 2025

#1151 in Algorithms

MIT license

8KB
115 lines

unirand

A Rust implementation of Marsaglia's Universal Random Number Generator

This program is based on "Toward a universal random number generator" by George Marsaglia, Arif Zaman, Wai Wan Tsang published in Statistics & Probability Letters Volume 9, Issue 1, January 1990, Pages 35-39 https://www.sciencedirect.com/science/article/abs/pii/016771529090092L?via%3Dihub


lib.rs:

Unirand Crate

This crate implements Marsaglia's Universal Random Number Generator. More details on the original paper.

Overview

The RNG uses a sequence of operations to generate uniformly distributed random numbers between 0 and 1. It has been designed with simplicity and reproducibility in mind.

Usage Instructions

To use this crate, add the following dependency to your Cargo.toml:

[dependencies]
unirand = "0.1.0"

Then, you can initialise and use the RNG in your project as follows:

use unirand::MarsagliaUniRng;

fn main() {
    let mut rng = MarsagliaUniRng::new();
    rng.rinit(170);
    println!("Random number: {}", rng.uni());
}

Further Information

See the documentation for individual functions and methods below for more details.

No runtime deps