{"id":20876000,"url":"https://github.com/juliarandom/stablerngs.jl","last_synced_at":"2025-12-26T16:58:22.425Z","repository":{"id":53194856,"uuid":"258781026","full_name":"JuliaRandom/StableRNGs.jl","owner":"JuliaRandom","description":"A Julia RNG with stable streams","archived":false,"fork":false,"pushed_at":"2024-04-26T22:16:57.000Z","size":37,"stargazers_count":54,"open_issues_count":8,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-26T23:24:28.658Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JuliaRandom.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-25T13:21:48.000Z","updated_at":"2024-04-26T23:24:35.015Z","dependencies_parsed_at":"2024-04-26T23:24:34.445Z","dependency_job_id":"c9507446-19c9-42f9-a489-72a5a3f15f02","html_url":"https://github.com/JuliaRandom/StableRNGs.jl","commit_stats":{"total_commits":37,"total_committers":2,"mean_commits":18.5,"dds":0.05405405405405406,"last_synced_commit":"b5a5d9367651a91965d6cf70f1477cd4a019d2da"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuliaRandom%2FStableRNGs.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuliaRandom%2FStableRNGs.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuliaRandom%2FStableRNGs.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuliaRandom%2FStableRNGs.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JuliaRandom","download_url":"https://codeload.github.com/JuliaRandom/StableRNGs.jl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243249011,"owners_count":20260768,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2024-11-18T06:49:27.499Z","updated_at":"2025-12-26T16:58:22.395Z","avatar_url":"https://github.com/JuliaRandom.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"# StableRNGs\n\n[![CI](https://github.com/JuliaRandom/StableRNGs.jl/actions/workflows/CI.yml/badge.svg)](https://github.com/JuliaRandom/StableRNGs.jl/actions/workflows/CI.yml)\n[![PkgEval](https://juliaci.github.io/NanosoldierReports/pkgeval_badges/S/StableRNGs.svg)](https://juliaci.github.io/NanosoldierReports/pkgeval_badges/report.html)\n\nThis package intends to provide a simple RNG with _stable_ streams, suitable\nfor tests in packages which need reproducible streams of random numbers\nacross Julia versions. Indeed, the Julia RNGs provided by default are\n[documented](https://docs.julialang.org/en/v1.4/stdlib/Random/#Reproducibility-1)\nto have non-stable streams (which for example enables some performance\nimprovements).\n\nThe `StableRNG` type provided by this package strives\nfor stability, but if bugs which require breaking this promise are found,\na new major version will be released with the fix.\n\n`StableRNG` is currently an alias for `LehmerRNG`, and implements a well understood\nlinear congruential generator (LCG); an LCG is not state of the art,\nbut is fast and is believed to have reasonably good statistical properties [1],\nsuitable at least for tests of a wide range of packages.\nThe choice of this particular RNG is based on its simplicity, which limits\nthe chances for bugs.\nNote that only `StableRNG` is exported from the package, and should be the only\ntype used in client code; `LehmerRNG` might be renamed, or might be made a distinct\ntype from `StableRNG` in any upcoming _minor_ (i.e. non-breaking) release.\n\nCurrently, this RNG requires explicit seeding (in the constructor\nor via `Random.seed!`), i.e. no random seed will be chosen for the user\nas is the case in e.g. `MersenneTwister()`.\n\nThe stable (guaranteed) API is\n* construction: `rng = StableRNG(seed::Integer)` (in particular the alias\n  `LehmerRNG` is currently _not_ part of the API)\n* seeding: `Random.seed!(rng::StableRNG, seed::Integer)`\n  (with `0 \u003c= seed \u003c= typemax(UInt64)`)\n* `rand(rng, X)` where `X` is any of the standard bit `Integer` types\n  (`Bool`, `Int8`, `Int16`, `Int32`, `Int64`, `Int128`,\n  `UInt8`, `UInt16`, `UInt32`, `UInt64`, `UInt128`)\n* `rand(rng, X)`, `randn(rng, X)`, `randexp(rng, X)` where `X` is a standard\n  bit `AbstractFloat` types (`Float16`, `Float32`, `Float64`)\n* array versions for these types, including\n  the mutating methods `rand!`, `randn!` and `randexp!`\n* `rand(rng, ::AbstractArray)` (e.g. `rand(rng, 1:9)`); the streams are the same\n  on 32-bits and 64-bits architectures\n* `shuffle(rng, ::AbstractArray)` and `shuffle!(rng, ::AbstractArray)`\n\nNote that the generated streams of numbers for scalars and arrays are the same,\ni.e. `rand(rng, X, n)` is equal to `[rand(rng, X) for _=1:n]` for a given `rng`\nstate.\n\nPlease open an issue for missing needed APIs.\n\n[1] `LehmerRNG` is implemented after the specific constants published by\nMelissa E. O'Neill in this\n[C++ implementation](https://gist.github.com/imneme/aeae7628565f15fb3fef54be8533e39c),\nand passes the Big Crush test (thanks to Kristoffer Carlsson for running it).\nSee also for example this\n[blog post](https://lemire.me/blog/2019/03/19/the-fastest-conventional-random-number-generator-that-can-pass-big-crush/).\n\n## Usage\n\nIn your tests, simply initialize an RNG with a given seed, and use\nit instead of the default provided one, e.g.\n\n```julia\nrng = StableRNG(123)\nA = randn(rng, 10, 10) # instead of randn(10, 10)\n@test inv(inv(A)) ≈ A\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliarandom%2Fstablerngs.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuliarandom%2Fstablerngs.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliarandom%2Fstablerngs.jl/lists"}