{"id":18986972,"url":"https://github.com/synesenom/ran","last_synced_at":"2026-05-25T20:04:31.388Z","repository":{"id":22451182,"uuid":"96284258","full_name":"synesenom/ran","owner":"synesenom","description":"Library for generating various random variables","archived":false,"fork":false,"pushed_at":"2024-07-24T04:34:58.000Z","size":31174,"stargazers_count":14,"open_issues_count":18,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-10T08:46:50.715Z","etag":null,"topics":["distribution","javascript","mcmc","random","statistics","test"],"latest_commit_sha":null,"homepage":"https://synesenom.github.io/ran/","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/synesenom.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2017-07-05T06:25:29.000Z","updated_at":"2025-01-05T15:08:33.000Z","dependencies_parsed_at":"2024-04-25T10:44:33.584Z","dependency_job_id":null,"html_url":"https://github.com/synesenom/ran","commit_stats":{"total_commits":510,"total_committers":4,"mean_commits":127.5,"dds":0.1705882352941176,"last_synced_commit":"b4bc662b80ed1570d9f0040c035aa6045cfbbcc1"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/synesenom%2Fran","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/synesenom%2Fran/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/synesenom%2Fran/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/synesenom%2Fran/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/synesenom","download_url":"https://codeload.github.com/synesenom/ran/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249795659,"owners_count":21326780,"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":["distribution","javascript","mcmc","random","statistics","test"],"created_at":"2024-11-08T16:37:55.166Z","updated_at":"2026-05-25T20:04:26.351Z","avatar_url":"https://github.com/synesenom.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CircleCI](https://img.shields.io/circleci/build/github/synesenom/ran)](https://app.circleci.com/pipelines/github/synesenom/ran)\n[![Coverage Status](https://coveralls.io/repos/github/synesenom/ran/badge.svg?branch=master)](https://coveralls.io/github/synesenom/ran?branch=master)\n[![npm](https://img.shields.io/npm/v/ranjs.svg)](https://www.npmjs.com/package/ranjs)\n[![Inline docs](http://inch-ci.org/github/synesenom/ran.svg?branch=master)](http://inch-ci.org/github/synesenom/ran)\n[![License](https://img.shields.io/npm/l/ranjs.svg)](https://www.npmjs.com/package/ranjs)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n[![CodeScene Code Health](https://codescene.io/projects/28921/status-badges/code-health)](https://codescene.io/projects/28921)\n# ranjs\n\nStatistical library for generating various seeded random variates, calculating likelihood functions and testing hypotheses (and much more).\n\nThe library includes:\n\n1. Statistical metrics and tests: a variety of central tendency, dispersion and shape statistics as well as statistical tests.\n2. Probability distributions: more than [130 continuous and discrete distributions](https://synesenom.github.io/ran/#dist.Distribution) (and counting), each tested rigorously for statistical correctness over a variety of parameters. Every distribution comes with the following methods:\n\n    2.1 fast and robust sampler.  \n    2.2 probability density/mass function.  \n    2.3 cumulative distribution function.  \n    2.4 quantile function.  \n    2.5 survival, hazard and cumulative hazard functions.  \n    2.6 likelihood and AIC/BIC methods.  \n    2.7 test method that uses Kolmogorov-Smirnov test for continuous or chi2 tests for discrete distributions.\n\n    Also, every distribution can be individually seeded.\n\n## install\n\n### browser\n\nJust include the [minified version](https://unpkg.com/ranjs@1.19.2/dist/ranjs.min.js) and add\n\n```\n\u003cscript type=\"text/javascript\" src=\"ran.min.js\"\u003e\u003c/script\u003e\n```\nThe module will be exported under `ranjs`.\n\n### node\n\n```\nnpm install ranjs\n```\n\n## usage\n\n### distributions\n\n```\nconst ran = require('ranjs')\n\n// Create a new generator for Skellam distribution with mu1 = 1 and mu2 = 3\nconst skellam = new ran.dist.Skellam(1, 3)\n\n// Generate 10K variates\nlet values = skellam.sample(1e4)\n\n// Test if samples indeed follow the specified distribution\nconsole.log(skellam.test(values))\n// =\u003e { statistics: 14.025360669436635, passed: true }\n\n// Evaluate PMF/CDF ...\nfor (let k = -10; k \u003c= 10; k++) {\n    console.log(k, skellam.pdf(k), skellam.cdf(k))\n}\n// =\u003e -4 0.10963424740027695 0.21542206959904264\n//    -3 0.1662284357019246 0.38165050508716936\n//    -2 0.20277318483535026 0.5844236896611729\n//    ...\n\n// ... or higher level statistical functions\nfor (let k = -4; k \u003c= 4; k++) {\n    console.log(k, skellam.hazard(k), skellam.cHazard(k))\n}\n// =\u003e -4 0.13973659359019766 0.24260937407418487\n//    -3 0.26882602325948046 0.4807014556249526\n//    -2 0.487932492278074 0.8780890224913454\n//    ...\n\n\n// Create another distribution and check their AIC\nconst skellam2 = new ran.dist.Skellam(1.2, 7.5)\nconsole.log(`Skellam(1, 3):     ${skellam.aic(values)}`)\n// =\u003e Skellam(1, 3):     41937.67252974663\n\nconsole.log(`Skellam(1.2, 7.5): ${skellam2.aic(values)}`)\n// =\u003e Skellam(1.2, 7.5): 66508.74299363888\n```\n\n## demo\n\nA demo observable notebook is available [here](https://beta.observablehq.com/@synesenom/ranjs-demo) to play around with the library.\n\n## API and documentation\n\nFor the full API and documentation, see: [https://synesenom.github.io/ran/](https://synesenom.github.io/ran/)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsynesenom%2Fran","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsynesenom%2Fran","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsynesenom%2Fran/lists"}