{"id":33938975,"url":"https://github.com/liborty/random","last_synced_at":"2026-03-27T02:44:28.198Z","repository":{"id":62443552,"uuid":"457001718","full_name":"liborty/random","owner":"liborty","description":"Simple and fast generation of random numbers in Rust ","archived":false,"fork":false,"pushed_at":"2023-12-20T12:23:03.000Z","size":116,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-14T03:17:16.225Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/liborty.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-02-08T15:57:51.000Z","updated_at":"2024-09-05T17:17:51.000Z","dependencies_parsed_at":"2023-11-01T05:26:50.746Z","dependency_job_id":null,"html_url":"https://github.com/liborty/random","commit_stats":{"total_commits":53,"total_committers":2,"mean_commits":26.5,"dds":"0.018867924528301883","last_synced_commit":"45be3333e78b8ce5da61e0632d6bddd1d41e43bc"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/liborty/random","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liborty%2Frandom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liborty%2Frandom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liborty%2Frandom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liborty%2Frandom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/liborty","download_url":"https://codeload.github.com/liborty/random/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liborty%2Frandom/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31011873,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-27T02:33:22.146Z","status":"ssl_error","status_checked_at":"2026-03-27T02:33:21.763Z","response_time":164,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-12-12T15:06:56.252Z","updated_at":"2026-03-27T02:44:28.184Z","avatar_url":"https://github.com/liborty.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ran [![crates.io](https://img.shields.io/crates/v/ran?logo=rust)](https://crates.io/crates/ran) [![crates.io](https://img.shields.io/crates/d/ran?logo=rust)](https://crates.io/crates/ran) [![GitHub last commit](https://img.shields.io/github/last-commit/liborty/random/HEAD?logo=github)](https://github.com/liborty/random) [![Actions Status](https://github.com/liborty/random/workflows/test/badge.svg)](https://github.com/liborty/random/actions)\n\n## Author: Libor Spacek\n\n## Description\n\nThe objective of this crate is to generate excellent quality random numbers fast, simply and with a minimal footprint. It is written in 100% safe Rust, is lightweight and has no dependencies at all.\n\nSeveral generating algorithms are available, plus a good range of utility functions. They can easily generate individual random numbers of various supported types, vectors, and vectors of vectors, filled with random numbers. Also, the ranges of values to be generated can be specified.\n\nThe main objective has been the ease of use but the algorithms are also very fast. They are mostly of the modern XOR and shift type, i.e. using those two low level instructions. The references are given in the text.\n\nIt is highly recommended to read [`tests/tests.rs`](https://github.com/liborty/random/blob/main/tests/tests.rs) with examples of usage. The output can be seen by clicking the 'test' badge at the top of this document and viewing the latest automated test log. (The badges also serve as links).\n\n## Getting Started\n\nThese algorithms use thread safe static seeds, initialised automatically at compile time to `systime` seconds. Should any program using this crate be recompiled every second for over `6.3376E+56` years, it will generate a new unique  random sequence every time. That means that the sequences are for practical purposes unpredictable. Warning: not in the cryptographic sense.\n\nTo force an unpredictable sequence at each run, use `set_seeds(0);`. This is useful for realistic simulations. The seed will be set to `systime` nanoseconds. The same sequence may then recur sometimes, with low probability of `2E-64`.\n\nFor repeatable random sequences, the seed must be initialised to a known value with `set_seeds(value);` Each u64 value will generate its own unique random sequence. This is useful for exact comparisons, e.g. different algorithms tested on exactly the same random data. The current value of seed can be obtained and saved using `get_seed()` and used at any later time to recreate the same sequence.\n\n## Function Names Syntax\n\nName ::= ran{Dimensionality}_Type  \nDimensionality ::= v|vv  \nType ::= u8|u16|u64|i64|f64|u64_range|i64_range|f64_range\n\n## Generating single random numbers of supported types\n\nExamples:\n\n```rust\nfn ran() {\n    println!(\"ran_u8:     {}\",ran_u8()); \n    println!(\"ran_u16:    {}\",ran_u16());\n    println!(\"ran_u64:    {}\",ran_u64()); \n    println!(\"ran_i64:    {}\",ran_i64());\n    println!(\"ran_f64:    {}\",ran_f64());\n    println!(\"ran_u64_range: {}\",ran_u64_range(1..=6));   \n    println!(\"ran_i64_range: {}\",ran_i64_range(-6..=6));   \n    println!(\"ran_f64_range: {}\",ran_f64_range(-100.0..=100.0));   \n}\n```\n\n## Generating vectors of random numbers of supported types\n\nExamples:\n\n```rust\nfn ranv()-\u003e Result\u003c(),Re\u003e {\n    println!(\"ranv_u8:     {}\",stringv(\u0026ranv_u8(5)?)); \n    println!(\"ranv_u16:    {}\",stringv(\u0026ranv_u16(5)?));\n    println!(\"ranv_u64:    {}\",stringv(\u0026ranv_u64(5)?)); \n    println!(\"ranv_i64:    {}\",stringv(\u0026ranv_i64(5)?));\n    println!(\"ranv_f64:    {}\",stringv(\u0026ranv_f64(5)?)); \n    println!(\"ranv_u64_range: {}\",stringv(\u0026ranv_u64_range(5,1..=6)?));   \n    println!(\"ranv_i64_range: {}\",stringv(\u0026ranv_i64_range(5,-6..=6)?));   \n    println!(\"ranv_f64_range: {}\",stringv(\u0026ranv_f64_range(5,-100_f64..=100_f64)?));  \n    Ok(()) \n}\n```\n\nNotes:\n\n- These functions check their arguments and potentially return errors.\n- `stringv` is a utility function to 'stringify' generic vectors for display.\n\n## Generating vectors of vectors of random numbers\n\nExamples:\n\n```rust\nfn ranvv()-\u003e Result\u003c(),Re\u003e {\n    set_seeds(0);\n    println!(\"ranvv_u8:     {}\",stringvv(\u0026ranvv_u8(2,5)?)); \n    println!(\"ranvv_u16:    {}\",stringvv(\u0026ranvv_u16(2,5)?));\n    println!(\"ranvv_u64:    {}\",stringvv(\u0026ranvv_u64(2,5)?)); \n    println!(\"ranvv_i64:    {}\",stringvv(\u0026ranvv_i64(2,5)?));\n    println!(\"ranvv_f64:    {}\",stringvv(\u0026ranvv_f64(2,5)?)); \n    println!(\"ranvv_u64_range: {}\",stringvv(\u0026ranvv_u64_range(2,5,1..=6)?));   \n    println!(\"ranvv_i64_range: {}\",stringvv(\u0026ranvv_i64_range(2,5,-6..=6)?));   \n    println!(\"ranvv_f64_range: {}\",stringvv(\u0026ranvv_f64_range(2,5,-100_f64..=100_f64)?));  \n    Ok(()) \n}\n```\n\nNotes:\n\n- These functions check their arguments and potentially return errors.\n- `stringvv` is a utility function to 'stringify' vectors of generic vectors for display.\n\n\n## Recent Releases (Latest First)\n\n**Version 2.0.1** Corrected swapped args d,n in `ranvv_f64_range`.\n\n**Version 2.0.0** Removed enumerations generics as an unnecessary complication from the user's point of view.\n\n**Version 1.1.5** Some minor comments and tests improvements.\n\n**Version 1.1.4** Restored `get_seed()` removed in `1.1.3`. It is useful for saving the state of SEED to reproduce the same sequence later.\n\n**Version 1.1.3** Some code simplification made possible by Rust 1.73.0. Also changed `rerror` utility to return `Result`.\n\n**Version 1.1.2** The seed is initialised at compile time. This means that the same executable will still always produce the same sequence. For complete unpredictability, `set_seeds(0)` can newly be used.\n\n**Version 1.1.1** The seeds are now automatically initiated to the `systime` seconds, so the sequences are unpredictable. Initialise the seed manually to a previously used value when the same sequence is required.\n\n**Version 1.1.0** More ergonomic error handling. Renamed `RanError\u003cString\u003e` alias type to `Re`. Introduced function `rerror`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliborty%2Frandom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliborty%2Frandom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliborty%2Frandom/lists"}