{"id":23722650,"url":"https://github.com/remko/lcg-random","last_synced_at":"2026-02-15T00:30:14.629Z","repository":{"id":22982116,"uuid":"26332374","full_name":"remko/lcg-random","owner":"remko","description":"(Predictable) LCG Random Number Generator","archived":false,"fork":false,"pushed_at":"2016-06-10T11:51:59.000Z","size":9,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-07T19:07:43.537Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/remko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-07T18:32:02.000Z","updated_at":"2016-06-10T11:47:15.000Z","dependencies_parsed_at":"2022-07-23T20:47:21.907Z","dependency_job_id":null,"html_url":"https://github.com/remko/lcg-random","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remko%2Flcg-random","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remko%2Flcg-random/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remko%2Flcg-random/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remko%2Flcg-random/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/remko","download_url":"https://codeload.github.com/remko/lcg-random/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238898309,"owners_count":19549127,"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-12-30T23:55:11.134Z","updated_at":"2026-02-15T00:30:14.584Z","avatar_url":"https://github.com/remko.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [lcg-random: (Predictable) LCG Random Number Generator](https://el-tramo.be/lcg-random)\n\nCreates a [Linear Congruential Generator](http://en.wikipedia.org/wiki/Linear_congruential_generator)\nfor generating random numbers. The random numbers are predictable/reproducable, which is useful for \n(unit) testing purposes.\n\n\n## Installation\n\n    npm install lcg-random --save\n\n\n## Usage\n\nA call to the exported function returns a function that generates a random number\non every call:\n\n\tvar lcgRandom = require(\"lcg-random\");\n\n\t// Outputs 0.000007826369259425611 0.13153778814316625 0.7556053221950332\n\tvar rand1 = lcgRandom();\n\tconsole.log(rand1(), rand1(), rand1());\n\n\t// Also outputs 0.000007826369259425611 0.13153778814316625 0.7556053221950332\n\tvar rand2 = lcgRandom();\n\tconsole.log(rand2(), rand2(), rand2());\n\n\n## API\n\n### `lcgRandom(options)`\n\nReturns a function that returns a random number between 0 and 1 every time it is called.\n\nThe function used is \n\n\u003e X\u003csub\u003en+1\u003c/sub\u003e = (multiplier \\* X\u003csub\u003en\u003c/sub\u003e + increment) % modulus\n\nEvery component of the function can be customized by setting it in the `options` argument.\nThe default values are the ones from Park and Miller's [MINSTD](https://en.wikipedia.org/wiki/Lehmer_random_number_generator).\n\n- **`options.seed`** - *number (0 \u0026leq; `options.seed` \u0026lt; `options.modulus`)*  \n    Seed (start value) for the generator.  \n    Default: 1\n\n- **`options.modulus`** - *modulus (0 \u0026lt; `options.modulus`)*  \n    Modulus for the generator.  \n    Default: 2\u003csup\u003e31\u003c/sup\u003e-1\n\n- **`options.multiplier`** - *modulus (0 \u0026lt; `options.multiplier` \u0026lt; `options.modulus`)*  \n    Multiplier for the generator.  \n    Default: 7\u003csup\u003e5\u003c/sup\u003e \n\n- **`options.increment`** - *modulus (0 \u0026leq; `options.increment` \u0026lt; `options.modulus`)*  \n    Increment for the generator.  \n    Default: 0\n\n\n## Project Status\n\n[![Build Status](https://travis-ci.org/remko/lcg-random.svg?branch=master)](https://travis-ci.org/remko/lcg-random)\n\n[![Coverage Status](https://coveralls.io/repos/remko/lcg-random/badge.png?branch=master)](https://coveralls.io/r/remko/lcg-random?branch=master)\n\n[![Browser Support](https://ci.testling.com/remko/lcg-random.png)\n](https://ci.testling.com/remko/lcg-random)\n\n\n## Changelog\n\n### 2.0.0 (2016-06-10)\n\n- Allow increment of 0 (enabling Lehmer RNGs) ([\\#1](https://github.com/remko/lcg-random/issues/1))\n- Use [MINSTD](https://en.wikipedia.org/wiki/Lehmer_random_number_generator) as default values ([\\#1](https://github.com/remko/lcg-random/issues/1))\n- Change default `seed` to 1 (to enable MINSTD)\n- Add bounds checks\n\n### 1.0.2 (2014-11-09)\n\n- Fix `index` in `package.json`\n\n### 1.0.1 (2014-11-07)\n\n- Initial version\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremko%2Flcg-random","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fremko%2Flcg-random","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremko%2Flcg-random/lists"}