{"id":13600254,"url":"https://github.com/flyingmutant/rand","last_synced_at":"2026-02-18T02:35:15.776Z","repository":{"id":45808375,"uuid":"513685955","full_name":"flyingmutant/rand","owner":"flyingmutant","description":"Fast, high quality alternative to math/rand and golang.org/x/exp/rand","archived":false,"fork":false,"pushed_at":"2024-11-05T14:19:19.000Z","size":236,"stargazers_count":240,"open_issues_count":3,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-11-16T14:20:21.408Z","etag":null,"topics":["golang","prng","prng-algorithms","random","random-generation"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/pgregory.net/rand","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flyingmutant.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":"2022-07-13T22:15:56.000Z","updated_at":"2025-10-13T10:14:09.000Z","dependencies_parsed_at":"2024-01-14T04:43:53.476Z","dependency_job_id":"b8c39a5d-1914-4e1b-aad4-c875837c3e39","html_url":"https://github.com/flyingmutant/rand","commit_stats":{"total_commits":114,"total_committers":2,"mean_commits":57.0,"dds":"0.10526315789473684","last_synced_commit":"cc89c0d3a5253851115db2ccc9cb9fd20bb9797f"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/flyingmutant/rand","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flyingmutant%2Frand","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flyingmutant%2Frand/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flyingmutant%2Frand/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flyingmutant%2Frand/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flyingmutant","download_url":"https://codeload.github.com/flyingmutant/rand/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flyingmutant%2Frand/sbom","scorecard":{"id":405115,"data":{"date":"2025-08-11","repo":{"name":"github.com/flyingmutant/rand","commit":"cc89c0d3a5253851115db2ccc9cb9fd20bb9797f"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.8,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/flyingmutant/rand/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/flyingmutant/rand/ci.yml/master?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Mozilla Public License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-18T21:00:19.413Z","repository_id":45808375,"created_at":"2025-08-18T21:00:19.413Z","updated_at":"2025-08-18T21:00:19.413Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29566402,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T00:47:08.760Z","status":"online","status_checked_at":"2026-02-18T02:00:09.468Z","response_time":162,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["golang","prng","prng-algorithms","random","random-generation"],"created_at":"2024-08-01T18:00:33.436Z","updated_at":"2026-02-18T02:35:15.761Z","avatar_url":"https://github.com/flyingmutant.png","language":"Go","readme":"# rand [![PkgGoDev][godev-img]][godev] [![CI][ci-img]][ci]\n\nFast, high quality alternative to `math/rand` and `golang.org/x/exp/rand`.\n\nCompared to these packages, `pgregory.net/rand`:\n\n- is API-compatible with all `*rand.Rand` methods and all top-level functions except `Seed()`,\n- is significantly faster, while improving the generator quality,\n- has simpler generator initialization:\n  - `rand.New()` instead of `rand.New(rand.NewSource(time.Now().UnixNano()))`\n  - `rand.New(1)` instead of `rand.New(rand.NewSource(1))`\n- is deliberately not providing top-level `Seed()` and the `Source` interface.\n\n## Benchmarks\n\nCompared to [math/rand/v2](https://pkg.go.dev/math/rand/v2) (top-level functions \u0026 PCG source):\n\n`Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz`, `linux/amd64`\n\n```\nname                    old time/op    new time/op    delta\nFloat64-8                 3.29ns ± 2%    3.55ns ±15%     +7.92%  (p=0.006 n=9+10)\nIntn-8                    3.86ns ± 1%    3.96ns ± 4%     +2.58%  (p=0.002 n=9+8)\nIntn_Big-8                6.46ns ± 2%    7.45ns ±15%    +15.35%  (p=0.000 n=8+10)\nUint64-8                  3.06ns ± 1%    3.20ns ± 2%     +4.75%  (p=0.000 n=10+8)\nRand_New                   107ns ± 1%     102ns ± 1%     -4.85%  (p=0.000 n=9+9)\nRand_ExpFloat64           13.0ns ± 1%     8.9ns ± 3%    -31.25%  (p=0.000 n=9+8)\nRand_Float32              7.67ns ± 3%    3.61ns ± 2%    -52.93%  (p=0.000 n=9+10)\nRand_Float64              7.95ns ± 3%    4.22ns ± 2%    -46.99%  (p=0.000 n=10+9)\nRand_Int                  6.79ns ± 1%    3.90ns ± 0%    -42.54%  (p=0.000 n=10+8)\nRand_Int31                6.79ns ± 1%    2.56ns ± 1%    -62.30%  (p=0.000 n=10+9)\nRand_Int31n               10.2ns ± 1%     4.2ns ± 1%    -59.15%  (p=0.000 n=9+9)\nRand_Int31n_Big           10.2ns ± 1%     4.2ns ± 1%    -59.25%  (p=0.000 n=9+10)\nRand_Int63                6.90ns ± 4%    3.92ns ± 1%    -43.20%  (p=0.000 n=9+8)\nRand_Int63n               10.3ns ± 5%     5.5ns ± 1%    -46.40%  (p=0.000 n=9+8)\nRand_Int63n_Big           28.8ns ± 1%     8.8ns ± 1%    -69.44%  (p=0.000 n=10+8)\nRand_Intn                 10.2ns ± 1%     5.5ns ± 0%    -46.75%  (p=0.000 n=9+8)\nRand_Intn_Big             28.7ns ± 1%     8.8ns ± 1%    -69.44%  (p=0.000 n=9+8)\nRand_NormFloat64          14.1ns ± 2%     9.1ns ± 1%    -35.19%  (p=0.000 n=9+9)\nRand_Perm                  951ns ± 5%     451ns ± 1%    -52.60%  (p=0.000 n=9+9)\nRand_Seed                 0.57ns ± 3%   46.09ns ± 1%  +7995.18%  (p=0.000 n=10+9)\nRand_Shuffle               711ns ± 1%     412ns ± 1%    -42.12%  (p=0.000 n=10+8)\nRand_ShuffleOverhead       638ns ± 3%     306ns ± 1%    -52.09%  (p=0.000 n=9+10)\nRand_Uint32               7.12ns ±12%    2.48ns ± 1%    -65.24%  (p=0.000 n=10+9)\nRand_Uint64               6.86ns ± 1%    3.93ns ± 0%    -42.64%  (p=0.000 n=8+9)\nShuffleSlice               284ns ± 1%     278ns ± 1%     -2.09%  (p=0.000 n=8+8)\n\nname                    old speed      new speed      delta\nUint64                  2.62GB/s ± 1%  2.48GB/s ± 7%     -5.30%  (p=0.000 n=10+9)\nRand_Uint32              564MB/s ±11%  1616MB/s ± 1%   +186.63%  (p=0.000 n=10+9)\nRand_Uint64             1.17GB/s ± 1%  2.03GB/s ± 0%    +74.32%  (p=0.000 n=8+9)\n\nname                    old alloc/op   new alloc/op   delta\nRand_New                   32.0B ± 0%     48.0B ± 0%    +50.00%  (p=0.000 n=10+10)\nRand_Perm                   416B ± 0%      416B ± 0%       ~     (all equal)\n\nname                    old allocs/op  new allocs/op  delta\nRand_New                    2.00 ± 0%      1.00 ± 0%    -50.00%  (p=0.000 n=10+10)\nRand_Perm                   1.00 ± 0%      1.00 ± 0%       ~     (all equal)\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eCompared to \u003ca href=\"https://pkg.go.dev/math/rand\"\u003emath/rand\u003c/a\u003e:\u003c/summary\u003e\n\n`Intel(R) Xeon(R) CPU E5-2680 v3 @ 2.50GHz`, `linux/amd64`\n\n```\nname                     old time/op    new time/op    delta\nFloat64-48                  180ns ± 8%       1ns ±12%   -99.66%  (p=0.000 n=10+9)\nIntn-48                     186ns ± 2%       1ns ±11%   -99.63%  (p=0.000 n=10+10)\nIntn_Big-48                 200ns ± 1%       1ns ±19%   -99.28%  (p=0.000 n=8+10)\nUint64-48                   193ns ± 5%       1ns ± 3%   -99.72%  (p=0.000 n=9+9)\nRand_New                   12.7µs ± 4%     0.1µs ± 6%   -99.38%  (p=0.000 n=10+10)\nRand_ExpFloat64            9.66ns ± 3%    5.90ns ± 3%   -38.97%  (p=0.000 n=10+10)\nRand_Float32               8.90ns ± 5%    2.04ns ± 4%   -77.05%  (p=0.000 n=10+10)\nRand_Float64               7.62ns ± 4%    2.93ns ± 3%   -61.50%  (p=0.000 n=10+10)\nRand_Int                   7.74ns ± 3%    2.92ns ± 2%   -62.30%  (p=0.000 n=10+10)\nRand_Int31                 7.81ns ± 3%    1.92ns ±14%   -75.39%  (p=0.000 n=10+10)\nRand_Int31n                12.7ns ± 3%     3.0ns ± 3%   -76.66%  (p=0.000 n=9+10)\nRand_Int31n_Big            12.6ns ± 4%     3.4ns ±10%   -73.39%  (p=0.000 n=10+10)\nRand_Int63                 7.78ns ± 4%    2.96ns ± 6%   -61.97%  (p=0.000 n=10+9)\nRand_Int63n                26.4ns ± 1%     3.6ns ± 3%   -86.56%  (p=0.000 n=10+10)\nRand_Int63n_Big            26.2ns ± 7%     6.2ns ± 4%   -76.53%  (p=0.000 n=10+10)\nRand_Intn                  14.4ns ± 5%     3.5ns ± 3%   -75.72%  (p=0.000 n=10+10)\nRand_Intn_Big              28.8ns ± 2%     6.0ns ± 6%   -79.03%  (p=0.000 n=10+10)\nRand_NormFloat64           10.7ns ± 6%     6.0ns ± 3%   -44.28%  (p=0.000 n=10+10)\nRand_Perm                  1.34µs ± 1%    0.39µs ± 3%   -70.86%  (p=0.000 n=9+10)\nRand_Read                   289ns ± 5%     104ns ± 5%   -64.00%  (p=0.000 n=10+10)\nRand_Seed                  10.9µs ± 4%     0.0µs ± 6%   -99.69%  (p=0.000 n=10+10)\nRand_Shuffle                790ns ± 4%     374ns ± 5%   -52.63%  (p=0.000 n=10+10)\nRand_ShuffleOverhead        522ns ± 3%     204ns ± 4%   -60.83%  (p=0.000 n=10+10)\nRand_Uint32                7.82ns ± 3%    1.72ns ± 3%   -77.98%  (p=0.000 n=10+9)\nRand_Uint64                9.59ns ± 3%    2.83ns ± 2%   -70.47%  (p=0.000 n=10+9)\n\nname                     old alloc/op   new alloc/op   delta\nRand_New                   5.42kB ± 0%    0.05kB ± 0%   -99.12%  (p=0.000 n=10+10)\nRand_Perm                    416B ± 0%      416B ± 0%      ~     (all equal)\n\nname                     old allocs/op  new allocs/op  delta\nRand_New                     2.00 ± 0%      1.00 ± 0%   -50.00%  (p=0.000 n=10+10)\nRand_Perm                    1.00 ± 0%      1.00 ± 0%      ~     (all equal)\n\nname                     old speed      new speed      delta\nRand_Read                 887MB/s ± 4%  2464MB/s ± 4%  +177.83%  (p=0.000 n=10+10)\nRand_Uint32               511MB/s ± 3%  2306MB/s ± 7%  +350.86%  (p=0.000 n=10+10)\nRand_Uint64               834MB/s ± 3%  2811MB/s ± 4%  +236.85%  (p=0.000 n=10+10)\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eCompared to \u003ca href=\"https://pkg.go.dev/golang.org/x/exp/rand\"\u003egolang.org/x/exp/rand\u003c/a\u003e:\u003c/summary\u003e\n\n`Intel(R) Xeon(R) CPU E5-2680 v3 @ 2.50GHz`, `linux/amd64`\n\n```\nname                     old time/op    new time/op    delta\nFloat64-48                  175ns ± 8%       1ns ±12%   -99.65%  (p=0.000 n=10+9)\nIntn-48                     176ns ±10%       1ns ±11%   -99.61%  (p=0.000 n=10+10)\nIntn_Big-48                 174ns ± 1%       1ns ±19%   -99.18%  (p=0.000 n=9+10)\nUint64-48                   157ns ± 5%       1ns ± 3%   -99.66%  (p=0.000 n=10+9)\nRand_New                   78.8ns ± 6%    78.3ns ± 6%      ~     (p=0.853 n=10+10)\nRand_ExpFloat64            8.94ns ± 6%    5.90ns ± 3%   -34.00%  (p=0.000 n=10+10)\nRand_Float32               9.67ns ± 5%    2.04ns ± 4%   -78.89%  (p=0.000 n=10+10)\nRand_Float64               8.56ns ± 5%    2.93ns ± 3%   -65.74%  (p=0.000 n=10+10)\nRand_Int                   5.75ns ± 3%    2.92ns ± 2%   -49.25%  (p=0.000 n=9+10)\nRand_Int31                 5.72ns ± 5%    1.92ns ±14%   -66.37%  (p=0.000 n=10+10)\nRand_Int31n                17.4ns ± 7%     3.0ns ± 3%   -82.87%  (p=0.000 n=10+10)\nRand_Int31n_Big            17.3ns ± 4%     3.4ns ±10%   -80.57%  (p=0.000 n=10+10)\nRand_Int63                 5.77ns ± 4%    2.96ns ± 6%   -48.73%  (p=0.000 n=10+9)\nRand_Int63n                17.0ns ± 2%     3.6ns ± 3%   -79.13%  (p=0.000 n=9+10)\nRand_Int63n_Big            26.5ns ± 2%     6.2ns ± 4%   -76.81%  (p=0.000 n=10+10)\nRand_Intn                  17.5ns ± 5%     3.5ns ± 3%   -79.94%  (p=0.000 n=10+10)\nRand_Intn_Big              27.5ns ± 3%     6.0ns ± 6%   -78.09%  (p=0.000 n=10+10)\nRand_NormFloat64           10.0ns ± 3%     6.0ns ± 3%   -40.45%  (p=0.000 n=10+10)\nRand_Perm                  1.31µs ± 1%    0.39µs ± 3%   -70.04%  (p=0.000 n=10+10)\nRand_Read                   334ns ± 1%     104ns ± 5%   -68.88%  (p=0.000 n=8+10)\nRand_Seed                  5.36ns ± 2%   33.73ns ± 6%  +528.91%  (p=0.000 n=10+10)\nRand_Shuffle               1.22µs ± 2%    0.37µs ± 5%   -69.36%  (p=0.000 n=10+10)\nRand_ShuffleOverhead        907ns ± 2%     204ns ± 4%   -77.45%  (p=0.000 n=10+10)\nRand_Uint32                5.20ns ± 5%    1.72ns ± 3%   -66.84%  (p=0.000 n=10+9)\nRand_Uint64                5.14ns ± 5%    2.83ns ± 2%   -44.85%  (p=0.000 n=10+9)\nRand_Uint64n               17.6ns ± 3%     3.5ns ± 2%   -80.32%  (p=0.000 n=10+10)\nRand_Uint64n_Big           27.3ns ± 2%     6.0ns ± 7%   -77.97%  (p=0.000 n=10+10)\nRand_MarshalBinary         30.5ns ± 1%     3.8ns ± 4%   -87.70%  (p=0.000 n=8+10)\nRand_UnmarshalBinary       3.22ns ± 4%    3.71ns ± 3%   +15.16%  (p=0.000 n=10+10)\n\nname                     old alloc/op   new alloc/op   delta\nRand_New                    48.0B ± 0%     48.0B ± 0%      ~     (all equal)\nRand_Perm                    416B ± 0%      416B ± 0%      ~     (all equal)\nRand_MarshalBinary          16.0B ± 0%      0.0B       -100.00%  (p=0.000 n=10+10)\nRand_UnmarshalBinary        0.00B          0.00B           ~     (all equal)\n\nname                     old allocs/op  new allocs/op  delta\nRand_New                     2.00 ± 0%      1.00 ± 0%   -50.00%  (p=0.000 n=10+10)\nRand_Perm                    1.00 ± 0%      1.00 ± 0%      ~     (all equal)\nRand_MarshalBinary           1.00 ± 0%      0.00       -100.00%  (p=0.000 n=10+10)\nRand_UnmarshalBinary         0.00           0.00           ~     (all equal)\n\nname                     old speed      new speed      delta\nRand_Read                 764MB/s ± 3%  2464MB/s ± 4%  +222.68%  (p=0.000 n=9+10)\nRand_Uint32               770MB/s ± 5%  2306MB/s ± 7%  +199.35%  (p=0.000 n=10+10)\nRand_Uint64              1.56GB/s ± 5%  2.81GB/s ± 4%   +80.32%  (p=0.000 n=10+10)\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eCompared to \u003ca href=\"https://pkg.go.dev/github.com/valyala/fastrand\"\u003egithub.com/valyala/fastrand\u003c/a\u003e:\u003c/summary\u003e\n\nNote that `fastrand` [does not](https://gist.github.com/flyingmutant/bf3bd489ee3c7a32f40714c11325d614)\ngenerate good random numbers.\n\n`Intel(R) Xeon(R) CPU E5-2680 v3 @ 2.50GHz`, `linux/amd64`\n\n```\nname       old time/op  new time/op  delta\nUint64-48  3.20ns ±35%  0.53ns ± 3%  -83.29%  (p=0.000 n=10+9)\nIntn-48    1.83ns ±21%  0.69ns ±11%  -62.35%  (p=0.000 n=10+10)\n```\n\u003c/details\u003e\n\n## FAQ\n\n### Why did you write this?\n\n`math/rand` is both slow and [not up to standards](\nhttps://gist.github.com/flyingmutant/ad5841f5e594aa8687fe47de34985e6a)\nin terms of quality (but can not be changed because of Go 1 compatibility promise).\n`golang.org/x/exp/rand` fixes some (but [not all](\nhttps://gist.github.com/flyingmutant/0b380f432308beaaf09c0a038f918aa4))\nquality issues, without improving the speed,\nand it seems that there is no active development happening there.\n\n### Should I use this or `math/rand/v2`?\n\nIf you are not counting nanoseconds, use `math/rand/v2`, it is a huge improvement\nover nearly all aspects of `math/rand`. If you are counting nanoseconds,\n`pgregory.net/rand` is still faster, without compromising quality.\n\n### How does this thing work?\n\nThis package builds on 4 primitives: raw 64-bit generation using `sfc64` or goroutine-local\n`runtime.fastrand64()`, floating-point generation using floating-point multiplication,\nand integer generation in range using 32.64 or 64.128 fixed-point multiplication.\n\n### Why is it fast?\n\nThe primitives selected are (as far as I am aware) about as fast as you can go\nwithout sacrificing quality. On top of that, it is mainly making sure the compiler\nis able to inline code, and a couple of micro-optimizations.\n\n### Why no `Source`?\n\nIn Go (but not in C++ or Rust) it is a costly abstraction that provides no real value.\nHow often do you use a non-default `Source` with `math/rand`?\n\n### Why no top-level `Seed()`?\n\nTop-level `Seed()` would require sharing global mutex-protected state between all top-level\nfunctions, which (unlike the goroutine-local state used) does not scale when the parallelism increases.\n\n### Why `sfc64`?\n\nI like it. It has withstood the test of time, with no known flaws or weaknesses despite\na lot of effort and CPU-hours spent on finding them. Also, it provides guarantees about period\nlength and distance between generators seeded with different seeds. And it is fast.\n\n### Why not...\n\n#### ...`pcg`?\n\nA bit slow. Otherwise, [`pcg64dxsm`](https://numpy.org/devdocs/reference/random/bit_generators/pcg64dxsm.html)\nis probably a fine choice.\n\n#### ...`xoshiro`/`xoroshiro`?\n\nQuite a bit of controversy and people finding weaknesses in variants of this design.\nDid you know that `xoshiro256**`, which author describes as an \"all-purpose, rock-solid generator\"\nthat \"passes all tests we are aware of\", fails them in seconds if you multiply the output by 57?\n\n#### ...`splitmix`?\n\nWith 64-bit state and 64-bit output, `splitmix64` outputs every 64-bit number exactly once\nover its 2^64 period — in other words, the probability of generating the same number is 0.\nA [birthday test](https://www.pcg-random.org/posts/birthday-test.html) will quickly find\nthis problem.\n\n#### ...`wyrand`?\n\nAn excellent generator if you are OK with slightly lower quality. Because its output function\n(unlike `splitmix`) is not a bijection, some outputs are more likely to appear than others.\nYou can easily observe this non-uniformity with\na [birthday test](https://gist.github.com/flyingmutant/cb69e96872023f9f580868e746d1128a).\nOn most modern platforms, top-level functions in this package use goroutine-local `wyrand`\ngenerators provided by the runtime as the best compromise between quality and speed\nof concurrent execution.\n\n#### ...`romu`?\n\nVery fast, but relatively new and untested. Also, no guarantees about the period length.\n\n## Status\n\n`pgregory.net/rand` is stable. In addition to API stability, deterministic pseudo-random\ngeneration produces the same results on 32-bit and 64-bit architectures, both little-endian\nand big-endian. Any observable change to these results would only occur together\nwith a major version bump.\n\n## License\n\n`pgregory.net/rand` is licensed under the [Mozilla Public License Version 2.0](./LICENSE). \n\n[godev-img]: https://pkg.go.dev/badge/pgregory.net/rand\n[godev]: https://pkg.go.dev/pgregory.net/rand\n[ci-img]: https://github.com/flyingmutant/rand/workflows/CI/badge.svg\n[ci]: https://github.com/flyingmutant/rand/actions\n","funding_links":[],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflyingmutant%2Frand","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflyingmutant%2Frand","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflyingmutant%2Frand/lists"}