{"id":15414962,"url":"https://github.com/lxsmnsyc/prd","last_synced_at":"2025-10-14T01:43:03.172Z","repository":{"id":71067434,"uuid":"148179904","full_name":"lxsmnsyc/PRD","owner":"lxsmnsyc","description":"A JS library for generating pseudo-random distribution.","archived":false,"fork":false,"pushed_at":"2018-09-11T10:31:20.000Z","size":5,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-10T03:51:44.803Z","etag":null,"topics":["pseudo-random","pseudorandom","random","random-generation","rng"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/lxsmnsyc.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":"2018-09-10T15:47:08.000Z","updated_at":"2023-02-07T22:24:11.000Z","dependencies_parsed_at":"2023-02-21T23:45:58.776Z","dependency_job_id":null,"html_url":"https://github.com/lxsmnsyc/PRD","commit_stats":{"total_commits":4,"total_committers":2,"mean_commits":2.0,"dds":0.25,"last_synced_commit":"93ae8ab5d80ffddfeba0a1c1c300ca3ba71d51e8"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lxsmnsyc%2FPRD","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lxsmnsyc%2FPRD/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lxsmnsyc%2FPRD/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lxsmnsyc%2FPRD/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lxsmnsyc","download_url":"https://codeload.github.com/lxsmnsyc/PRD/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240981558,"owners_count":19888346,"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":["pseudo-random","pseudorandom","random","random-generation","rng"],"created_at":"2024-10-01T17:05:21.856Z","updated_at":"2025-10-14T01:42:58.134Z","avatar_url":"https://github.com/lxsmnsyc.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PRD\nA JS library for generating pseudo-random distribution.\n\n## What is PRD?\nfrom the [Dota 2 Gamepedia page](https://dota2.gamepedia.com/Random_distribution):\n\u003e The uniform or true random distribution describes the probability of random event that underlies no manipulation of the chance depending on earlier outcomes. This means that every \"roll\" operates independently.\n\n\u003e The pseudo-random distribution (often shortened to PRD) in Dota 2 refers to a statistical mechanic of how certain probability-based items and abilities work. In this implementation the event's chance increases every time it does not occur, but is lower in the first place as compensation. This results in the effects occurring more consistently.\n\n\u003e The probability of an effect to occur (or proc) on the Nth test since the last successful proc is given by P(N) = C × N. For each instance which could trigger the effect but does not, the PRD augments the probability of the effect happening for the next instance by a constant C. This constant, which is also the initial probability, is lower than the listed probability of the effect it is shadowing. Once the effect occurs, the counter is reset. \n\nTL;DR it keeps random-based occurences from games from being luck-based. PRD increases the chances of occuring whenever the random chance fails to occur. \n\n## How to use\n### Importing\nfor client-side JS\n```html\n    \u003cscript type=\"text/javascript\" src=\"/path/to/prd.js\"\u003e\u003c/script\u003e\n```\n\nfor NodeJS\n```js\n    const PRD = require(\"prd\").default;\n```\n\nfor ES6\n```js\n    import PRD from \"prd\";\n```\n### Creating a PRD\nThe PRD constructor takes a number value, namely \"chance\", which is in the range of 0 to 1\n```js\n    let prd = new PRD(0.25);\n```\n\n### Generating success\n```js\n    const success = prd.next();\n```\nWhat the PRD can do is that if you call the next() method, it tells whether the next result would be a fail or a success. Once the PRD successes, the PRD progress will reset back to 1, since the succession is based from P(N) = N*C where N is the number of attempts and C is the constant, calculated from the given chance. (see the wikipedia page.)\n\n### Resetting\n```js\n    prd.reset();\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flxsmnsyc%2Fprd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flxsmnsyc%2Fprd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flxsmnsyc%2Fprd/lists"}