{"_id":"randy","_rev":"92-62c437d83afa904e013767928507cfd4","name":"randy","description":"Random utilities based on WELL-1024a PRNG.","dist-tags":{"latest":"1.5.1"},"versions":{"1.0.0":{"name":"randy","version":"1.0.0","description":"Utilities around Math.random() or supplied equivalent.","author":{"name":"Helge Skogly Holm","email":"helge.holm@gmail.com"},"keywords":["random"],"bugs":{"email":"helge.holm@gmail.com","url":"http://github.com/deestan/randy/issues"},"main":"./index","repository":{"type":"git","url":"git://github.com/deestan/randy.git"},"devDependencies":{"mocha":"1.1.0","uglify-js":"1.3.0"},"scripts":{"test":"./test-both.js","minify":"node_modules/uglify-js/bin/uglifyjs --unsafe -o lib/randy.min.js lib/randy.js","test-distribution":"./test-both.js -R landing -t 10000 -s 10000 test-distribution/","preinstall":"git submodule update --init --recursive"},"_npmUser":{"name":"deestan","email":"helge.holm@gmail.com"},"_id":"randy@1.0.0","dependencies":{},"optionalDependencies":{},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.1.21","_nodeVersion":"v0.6.18","_defaultsLoaded":true,"dist":{"shasum":"35f3722678e85fd0daf7be4bdd416e93608b86ff","tarball":"https://registry.npmjs.org/randy/-/randy-1.0.0.tgz","integrity":"sha512-wu2XBYz4umHE9wP4xgpCdJgcgvunBJe7RzQkbZQ1/RxGUfWCDU4lfrmMxPu6sQiRxGmxmy+rtq4QQvS1TP/RFA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDY+J/JeS96CjXaHIUhs+65HxM/DIbIjxTYGuCGOUbA2AiBQuh/BTzhKkL6XU5UukwDl/oMxyJ03W+aHefoW7xpqtA=="}]},"maintainers":[{"name":"deestan","email":"helge.holm@gmail.com"}],"directories":{}},"1.1.0":{"name":"randy","version":"1.1.0","description":"Random utilities based on WELL-1024a PRNG.","author":{"name":"Helge Skogly Holm","email":"helge.holm@gmail.com"},"keywords":["random"],"bugs":{"email":"helge.holm@gmail.com","url":"http://github.com/deestan/randy/issues"},"main":"./index","repository":{"type":"git","url":"git://github.com/deestan/randy.git"},"devDependencies":{"mocha":"1.1.0","uglify-js":"1.3.0"},"scripts":{"test":"node_modules/mocha/bin/mocha","minify":"node_modules/uglify-js/bin/uglifyjs --unsafe -o lib/randy.min.js lib/randy.js","test-distribution":"node_modules/mocha/bin/mocha -R landing -t 300000 -s 300000 test-distribution/","qc":"node ./qc.js","preinstall":"git submodule update --init --recursive"},"_npmUser":{"name":"deestan","email":"helge.holm@gmail.com"},"_id":"randy@1.1.0","dependencies":{},"optionalDependencies":{},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.1.21","_nodeVersion":"v0.6.18","_defaultsLoaded":true,"dist":{"shasum":"7eaa14934ab23c70d58a8e36d07374649793130c","tarball":"https://registry.npmjs.org/randy/-/randy-1.1.0.tgz","integrity":"sha512-sLQZ3MYWvMYnLUe727vNjSUNZRMxRdUH2HFkdobH6+HjQO4nydVD/WGQglEp9U/MrvPreeX+CQxXeo9G5vC9XQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC+wr81EcbMYRwHATDRMCSF0TWI+xLGc1NjW3BBFLv/rwIhAP3FEHP9WJX8xE0vckw/QPsTkEE8wQxiGrhakEm4iVTj"}]},"maintainers":[{"name":"deestan","email":"helge.holm@gmail.com"}],"directories":{}},"1.1.1":{"name":"randy","version":"1.1.1","description":"Random utilities based on WELL-1024a PRNG.","author":{"name":"Helge Skogly Holm","email":"helge.holm@gmail.com"},"keywords":["random"],"bugs":{"email":"helge.holm@gmail.com","url":"http://github.com/deestan/randy/issues"},"main":"./index","repository":{"type":"git","url":"git://github.com/deestan/randy.git"},"devDependencies":{"mocha":"1.1.0","uglify-js":"1.3.0"},"scripts":{"test":"node_modules/mocha/bin/mocha","minify":"node_modules/uglify-js/bin/uglifyjs --unsafe -o lib/randy.min.js lib/randy.js","test-distribution":"node_modules/mocha/bin/mocha -R landing -t 300000 -s 300000 test-distribution/","qc":"node ./qc.js","prepare-webclient-tests":"git submodule update --init --recursive"},"_npmUser":{"name":"deestan","email":"helge.holm@gmail.com"},"_id":"randy@1.1.1","dependencies":{},"optionalDependencies":{},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.1.21","_nodeVersion":"v0.6.18","_defaultsLoaded":true,"dist":{"shasum":"3221b455d2ecc4dcb0fe6be594fa1c7b7be6830d","tarball":"https://registry.npmjs.org/randy/-/randy-1.1.1.tgz","integrity":"sha512-t0ZFWONOoSmOOukeQTvG8AORorB7bTOOFVSfHu1hjM/VtF+wOE0H436kaJMrPlE4XZ3a/m1+Y21g2IaY6nNG1g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC/7mXxprf/85dm5TP841/EI5+o8WizY2PDyj6L+jHHkQIgUkmAzpwwWH/fjewkwhIU6xUZyMv94/l4EAfngsokKC0="}]},"maintainers":[{"name":"deestan","email":"helge.holm@gmail.com"}],"directories":{}},"1.2.0":{"name":"randy","version":"1.2.0","description":"Random utilities based on WELL-1024a PRNG.","author":{"name":"Helge Skogly Holm","email":"helge.holm@gmail.com"},"keywords":["random"],"bugs":{"email":"helge.holm@gmail.com","url":"http://github.com/deestan/randy/issues"},"main":"./index","repository":{"type":"git","url":"git://github.com/deestan/randy.git"},"devDependencies":{"mocha":"1.1.0","uglify-js":"1.3.0"},"scripts":{"test":"node_modules/mocha/bin/mocha","minify":"node_modules/uglify-js/bin/uglifyjs --unsafe -o lib/randy.min.js lib/randy.js","test-distribution":"node_modules/mocha/bin/mocha -R landing -t 300000 -s 300000 test-distribution/","qc":"node ./qc.js","prepare-webclient-tests":"git submodule update --init --recursive"},"_npmUser":{"name":"deestan","email":"helge.holm@gmail.com"},"_id":"randy@1.2.0","dependencies":{},"optionalDependencies":{},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.1.21","_nodeVersion":"v0.6.18","_defaultsLoaded":true,"dist":{"shasum":"8ee21aaf2a925d8e01139af36838e12219ecab0c","tarball":"https://registry.npmjs.org/randy/-/randy-1.2.0.tgz","integrity":"sha512-1p3ouBVDwIaXDsZVB08n15EWqdC4SFKk2IZNrEDYEITYylPMBbHQ9RR3/k+oiqDWKKFzcY3Ad5Hsg2VXq0xrLQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDLipIBApBIzxHeKaXm6eF4KZzAld9vgdRil0Qm7Ib1jAiEAk1hWmOm5/Zonk2uOPP9E3nbiWHUAoCZL6i56TlGloTE="}]},"maintainers":[{"name":"deestan","email":"helge.holm@gmail.com"}],"directories":{}},"1.3.0":{"name":"randy","version":"1.3.0","description":"Random utilities based on WELL-1024a PRNG.","author":{"name":"Helge Skogly Holm","email":"helge.holm@gmail.com"},"keywords":["random"],"bugs":{"email":"helge.holm@gmail.com","url":"http://github.com/deestan/randy/issues"},"main":"./index","repository":{"type":"git","url":"git://github.com/deestan/randy.git"},"devDependencies":{"mocha":"~1.2.0","uglify-js":"~1.3.0"},"scripts":{"test":"node_modules/mocha/bin/mocha","minify":"node_modules/uglify-js/bin/uglifyjs --unsafe -o lib/randy.min.js lib/randy.js","test-distribution":"node_modules/mocha/bin/mocha -R landing -t 300000 -s 300000 test-distribution/","qc":"node ./qc.js","prepare-webclient-tests":"git submodule update --init --recursive"},"_npmUser":{"name":"deestan","email":"helge.holm@gmail.com"},"_id":"randy@1.3.0","dependencies":{},"optionalDependencies":{},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.1.21","_nodeVersion":"v0.8.0","_defaultsLoaded":true,"dist":{"shasum":"f339ab1b88b022d07e7c71d4aa9ee63c1f7086ee","tarball":"https://registry.npmjs.org/randy/-/randy-1.3.0.tgz","integrity":"sha512-lJMB7jGxFAleuVYZuQyu1XJmoYiKyd1wRwQst6toxmJigRrNZ6w/SP2XrLpJOpX9oRX4dThdemEFM7QiiO5gyw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAXF8T0MyCJtBbFpnPGV+dUS6YE7LHZGWoSwMbNByIqYAiEA7TbpeiVr81Lb9iyR8/DDhb1MZNnedxU+3M3PV6KOQXM="}]},"maintainers":[{"name":"deestan","email":"helge.holm@gmail.com"}],"directories":{}},"1.3.1":{"name":"randy","version":"1.3.1","description":"Random utilities based on WELL-1024a PRNG.","author":{"name":"Helge Skogly Holm","email":"helge.holm@gmail.com"},"keywords":["random"],"bugs":{"url":"http://github.com/deestan/randy/issues","email":"helge.holm@gmail.com"},"main":"./index","repository":{"type":"git","url":"http://github.com/deestan/randy.git"},"devDependencies":{"mocha":"~1.2.0","uglify-js":"~1.3.0"},"scripts":{"test":"node_modules/mocha/bin/mocha","minify":"node_modules/uglify-js/bin/uglifyjs --unsafe -o lib/randy.min.js lib/randy.js","test-distribution":"node_modules/mocha/bin/mocha -R landing -t 300000 -s 300000 test-distribution/","qc":"node ./qc.js","prepare-webclient-tests":"git submodule update --init --recursive"},"_id":"randy@1.3.1","dist":{"shasum":"6c3cbd990ca37ba0570b54d46c963959d5eeea65","tarball":"https://registry.npmjs.org/randy/-/randy-1.3.1.tgz","integrity":"sha512-+hFC86z08D2daPPGEH2SJis+prGzurOQ+LuyFq8IWcdMbOSqObCBSk9MezPt6rlWfzPNuFm7ZXkc0ez03Gysrg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC3xrSyA8JsAeK3GV7fCz2fKIdASSXgb5WmnAfp1AnusQIhAJIFmj0cs7EoIXm8tz1Ur44zlrjOe+N9vgeMHcagGuGs"}]},"maintainers":[{"name":"deestan","email":"helge.holm@gmail.com"}],"directories":{}},"1.4.0":{"name":"randy","version":"1.4.0","description":"Random utilities based on WELL-1024a PRNG.","author":{"name":"Helge Skogly Holm","email":"helge.holm@gmail.com"},"keywords":["random"],"bugs":{"url":"http://github.com/deestan/randy/issues","email":"helge.holm@gmail.com"},"main":"./index","repository":{"type":"git","url":"http://github.com/deestan/randy.git"},"devDependencies":{"mocha":"~1.2.0","uglify-js":"~1.3.0"},"scripts":{"test":"node_modules/mocha/bin/mocha","minify":"node_modules/uglify-js/bin/uglifyjs --unsafe -o lib/randy.min.js lib/randy.js","test-distribution":"node_modules/mocha/bin/mocha -R landing -t 300000 -s 300000 test-distribution/","qc":"node ./qc.js","prepare-webclient-tests":"git submodule update --init --recursive"},"_id":"randy@1.4.0","dist":{"shasum":"1fd18f1f5e9404ce9feceef0fe7f996f20262f89","tarball":"https://registry.npmjs.org/randy/-/randy-1.4.0.tgz","integrity":"sha512-W0K0A/smw1XjOweVqnzVC10CAd9n6hhHdjyp2Jv8fxLISVIQvdf8gh1UNH+EHMs/MZMTo7nYjBti+KfKgmFhNw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDceJRk/1kqLsTEP7X/6uIiryWOtFwLcElk97dYUgNkPgIgOEACFN+fPGkSXWal5Ipg240qaEE3BHF5ms/Wbb6ZWgY="}]},"maintainers":[{"name":"deestan","email":"helge.holm@gmail.com"}],"directories":{}},"1.4.1":{"name":"randy","version":"1.4.1","description":"Random utilities based on WELL-1024a PRNG.","author":{"name":"Helge Skogly Holm","email":"helge.holm@gmail.com"},"keywords":["random"],"bugs":{"url":"http://github.com/deestan/randy/issues","email":"helge.holm@gmail.com"},"main":"./index","repository":{"type":"git","url":"http://github.com/deestan/randy.git"},"devDependencies":{"mocha":"~1.2.0","uglify-js":"~1.3.0"},"scripts":{"test":"node_modules/mocha/bin/mocha","prepublish":"node ./qc.js","minify":"node_modules/uglify-js/bin/uglifyjs --unsafe -o lib/randy.min.js lib/randy.js","test-distribution":"node_modules/mocha/bin/mocha -R landing -t 300000 -s 300000 test-distribution/","prepare-webclient-tests":"git submodule update --init --recursive"},"_id":"randy@1.4.1","dist":{"shasum":"65b97bb3830ff45a56727c0f60fe706db34bc223","tarball":"https://registry.npmjs.org/randy/-/randy-1.4.1.tgz","integrity":"sha512-mGwjE/MmXX6FfyCkBcIzqJxbKPtWlaCGs7Z0hnDVqJo0RlgaljUAWAFo1EKD0POPz43hZVAdh8i0Zz//e2vl9Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDi5qGAGRYAkW29PuBEJgLo1A98jtyMRGvan8foYAQxiwIgMaOILryHhiNoflkG0IjrunFcZm6EaoIVwCCUeCOt/hs="}]},"maintainers":[{"name":"deestan","email":"helge.holm@gmail.com"}],"directories":{}},"1.4.2":{"name":"randy","version":"1.4.2","description":"Random utilities based on WELL-1024a PRNG.","author":{"name":"Helge Skogly Holm","email":"helge.holm@gmail.com"},"keywords":["random"],"bugs":{"url":"http://github.com/deestan/randy/issues","email":"helge.holm@gmail.com"},"main":"./index","repository":{"type":"git","url":"http://github.com/deestan/randy.git"},"devDependencies":{"mocha":"~1.2.0","uglify-js":"~1.3.0"},"scripts":{"test":"node_modules/mocha/bin/mocha","prepublish":"node ./qc.js","minify":"node_modules/uglify-js/bin/uglifyjs --unsafe -o lib/randy.min.js lib/randy.js","test-distribution":"node_modules/mocha/bin/mocha -R landing -t 300000 -s 300000 test-distribution/","prepare-webclient-tests":"git submodule update --init --recursive"},"_id":"randy@1.4.2","dist":{"shasum":"3be4dd53d9ba675acde117fe9674dcf81c37ff89","tarball":"https://registry.npmjs.org/randy/-/randy-1.4.2.tgz","integrity":"sha512-PShDACmR/UAUTCtcurDGP5cdiWQgqZEMxFJff9uZyft/26GNod2nt4iGnz2SnHXRPPcAt3/UOsTr/feLMzsS5g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCrXbM9hJBd3PxmNuxlSt/8OMT72OJZAZIbjM36coFJJQIgRFSR+02l53Ar8NTQ9X+SwefbxNz19BuRVRALKzne9kw="}]},"_from":".","_npmVersion":"1.2.15","_npmUser":{"name":"deestan","email":"helge.holm@gmail.com"},"maintainers":[{"name":"deestan","email":"helge.holm@gmail.com"}],"directories":{}},"1.4.3":{"name":"randy","version":"1.4.3","description":"Random utilities based on WELL-1024a PRNG.","author":{"name":"Helge Skogly Holm","email":"helge.holm@gmail.com"},"keywords":["random"],"bugs":{"url":"http://github.com/deestan/randy/issues","email":"helge.holm@gmail.com"},"main":"./index","repository":{"type":"git","url":"http://github.com/deestan/randy.git"},"devDependencies":{"mocha":"~1.2.0","uglify-js":"~1.3.0"},"scripts":{"test":"node_modules/mocha/bin/mocha","prepublish":"node ./qc.js","minify":"node_modules/uglify-js/bin/uglifyjs --unsafe -o lib/randy.min.js lib/randy.js","test-distribution":"node_modules/mocha/bin/mocha -R landing -t 300000 -s 300000 test-distribution/","prepare-webclient-tests":"git submodule update --init --recursive"},"_id":"randy@1.4.3","dist":{"shasum":"351e997716adb5ea1cd84e13a6e66d95b71e9dbf","tarball":"https://registry.npmjs.org/randy/-/randy-1.4.3.tgz","integrity":"sha512-UCjD8R+2w0zYnGxl8BBPdzQOjvYICZVYC6gmxUDch51oGkySJhUXqlmtBWlAWlRlgwVXxcoAe/E+bgq4Nu5APg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDMNas9DCF0x4P279SpInQdh33YEWZAywac3NpRNu5UwAiEA/GKeCDr7NW8dsUzch+B9KI3SYAsnoPzXH797go76HSA="}]},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"deestan","email":"helge.holm@gmail.com"},"maintainers":[{"name":"deestan","email":"helge.holm@gmail.com"}],"directories":{}},"1.5.0":{"name":"randy","version":"1.5.0","description":"Random utilities based on WELL-1024a PRNG.","author":{"name":"Helge Skogly Holm","email":"helge.holm@gmail.com"},"license":"MIT","keywords":["random"],"bugs":{"url":"http://github.com/deestan/randy/issues","email":"helge.holm@gmail.com"},"main":"./index","repository":{"type":"git","url":"http://github.com/deestan/randy.git"},"devDependencies":{"mocha":"~1.2.0","uglify-js":"~1.3.0"},"scripts":{"test":"node_modules/mocha/bin/mocha","prepublish":"npm test && npm run-script browser && npm run-script test-distribution && echo Prepublish Checks OK","browser":"node ./bundle.js && node_modules/uglify-js/bin/uglifyjs --unsafe -o browser/randy.min.js browser/randy.js","test-distribution":"node_modules/mocha/bin/mocha -R landing -t 300000 -s 300000 test-distribution/","prepare-webclient-tests":"git submodule update --init --recursive"},"dependencies":{"prng-well1024a":"~1.0.0"},"_id":"randy@1.5.0","dist":{"shasum":"ce826203ad3e54648ddd5ab4181d96804dddcdb9","tarball":"https://registry.npmjs.org/randy/-/randy-1.5.0.tgz","integrity":"sha512-QzBNvg46pPHRcyfMiKuYCk0t8yeWZcNyPsiTRC0s/MUresJxWLuVvx3oz6ACtRY13OrHf85tbWp6GWm2IgEu8w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFaJ1w0eCoUbyaeJbon8ZR+oIZsJyLQtQZP3Y3c8IDoWAiEAhlRK4FVhnQ5557Yv7YusVPzPQz5HTIlma3VJLfowhWw="}]},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"deestan","email":"helge.holm@gmail.com"},"maintainers":[{"name":"deestan","email":"helge.holm@gmail.com"}],"directories":{}},"1.5.1":{"name":"randy","version":"1.5.1","description":"Random utilities based on WELL-1024a PRNG.","author":{"name":"Helge Skogly Holm","email":"helge.holm@gmail.com"},"license":"MIT","keywords":["random"],"bugs":{"url":"http://github.com/deestan/randy/issues","email":"helge.holm@gmail.com"},"main":"./index","repository":{"type":"git","url":"http://github.com/deestan/randy.git"},"devDependencies":{"mocha":"~1.2.0","uglify-js":"~1.3.0"},"scripts":{"test":"node_modules/mocha/bin/mocha","prepublish":"npm test && npm run-script browser && npm run-script test-distribution && echo Prepublish Checks OK","browser":"node ./bundle.js && node_modules/uglify-js/bin/uglifyjs --unsafe -o browser/randy.min.js browser/randy.js","test-distribution":"node_modules/mocha/bin/mocha -R landing -t 300000 -s 300000 test-distribution/","prepare-webclient-tests":"git submodule update --init --recursive"},"dependencies":{"prng-well1024a":"~1.0.0"},"_id":"randy@1.5.1","dist":{"shasum":"e7dc086a0ecb8bef7d67356642cd2a33f962465c","tarball":"https://registry.npmjs.org/randy/-/randy-1.5.1.tgz","integrity":"sha512-xCxHBrX08xQo8KoyZgOlM9fQbHK0oDvBl/k4+kPVGBDqfbL4c7N6uxiWTJnkJRkkg4hRrf/3CH8Vt1HiaQ2IVQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCs2YWM1QMkYj3FWpz61R/S7Kb5reJOWgSyxEtIxHDsPQIgeZ9fPLaG5O4KEsPm4UkzSxqvkfJed4hPIbA9pU5Up2Y="}]},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"deestan","email":"helge.holm@gmail.com"},"maintainers":[{"name":"deestan","email":"helge.holm@gmail.com"}],"directories":{}}},"readme":"# randy.js\n\n[![NPM](https://nodei.co/npm/randy.png)](https://nodei.co/npm/randy/)\n\nRandy is a utility module inspired by Python's very handy standard\nmodule \"random\".  It contains a PRNG and useful randomness functions.\n\nAll functions are based on a JavaScript implementation of\n[WELL-1024a](http://en.wikipedia.org/wiki/Well_equidistributed_long-period_linear),\nwith up to 53-bit precision.  The reason for this is that the built-in\n`Math.random()` function is\n[implementation-dependent](http://www.ecma-international.org/publications/standards/Ecma-262.htm)\nand therefore of very limited usefulness, as you risk running into\ncrappy implementations.  Even the V8 engine (used by Node.js) only\nprovides 32-bit entropy, and is based on the platform-dependent C++\n`rand()` function.\n\n## Quick Examples\n\n```javascript\nvar a = randy.randInt(100);\n// a == 42\n```\n\n```javascript\nvar d = randy.shuffle([\"J spades\", \"K hearts\", \"10 hearts\"]);\n// d == [ \"K hearts\", \"J spades\", \"10 hearts\" ]\n```\n\n```javascript\nvar c = randy.choice([\"heads\", \"tails\"]);\n// c == \"heads\"\n```\n\n<a name=\"download\" />\n## Download\n\nFor [Node.js](http://nodejs.org/), use [npm](http://npmjs.org/):\n\n    npm install randy\n\n<a name=\"browser\" />\n### In the Browser\n\nDownload and include as a `<script>`.  The module will be available as\nthe global object `randy`.\n\n__Development:__ [randy.js](https://github.com/deestan/randy/raw/master/browser/randy.js) - 12Kb Uncompressed\n\n__Production:__ [randy.min.js](https://github.com/deestan/randy/raw/master/browser/randy.min.js) - 3.5Kb Minified\n\n__Example__\n\n```html\n<img id=\"computerHandImg\">\n<script src=\"randy.min.js\"></script>\n<script>\n    var h = document.getElementById(\"computerHandImg\");\n    h.src = randy.choice([\n        \"/img/rock\",\n        \"/img/paper\",\n        \"/img/kitten\"\n    ]);\n</script>\n```\n\n## Documentation\n\n### Randomness Functions\n\n* [randInt](#randInt)\n* [choice](#choice)\n* [shuffle](#shuffle)\n* [shuffleInplace](#shuffleInplace)\n* [sample](#sample)\n* [random](#random)\n* [uniform](#uniform)\n* [triangular](#triangular)\n* [getRandBits](#getRandBits)\n\n### State Functions\n\n* [getState](#getState)\n* [setState](#setState)\n* [instance](#instance)\n\n### High-Precision Functions\n\nAll the above randomness functions use 32-bit precision if possible,\nbut will use 53-bit precision if they need to go outside the 32-bit\nrange.\n\nThe randomness functions are also available in always-53-bit-precision\nversions, under the `good` namespace.  If you're working with values\nover 65536 or so, imbalances of 0.01% will start to creep in, and a\nhigher precision will reduce this problem.\n\nThese functions take about 35% longer to run than the ones available\ndirectly under `randy`.\n\n__Example__\n\n```javascript\n// Generate example salary between 1,000,000 and 5,000,000\n// with values clustering around 2,000,000.\nvar salary = randy.good.triangular(1000000, 5000000, 2000000);\n```\n\n### Maximally Uniform Functions\n\nThe randomness functions are also available in maximally uniform\nversions, under the `best` namespace.\n\nRandom integer calculations in the `randy` and `randy.good` functions\nare done via a modulo of a large random unsigned integer.  This will\nslightly favour lower numbers, but it is fast, and good enough for\nmost use cases.  However, if you wish to avoid this imbalance, you can\nuse these functions.\n\nThese functions take on average 110% longer to run than the ones\navailable directly under `randy`.\n\n__Example__\n\n```javascript\nvar numbers = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,\n                13, 14, 15, 16, 17, 18, 19, 20, 21, 22 ];\nvar lottery = randy.best.sample(numbers, 7);\n```\n\n---------------------------------------\n\n## Randomness Functions\n\n<a name=\"randInt\" />\n### randInt (min, max, step)\n### randInt (min, max)\n### randInt (max)\n### randInt ()\n\nReturns a random integer `i` such that `min <= i < max`.\n\nIf `step` is provided, then additionally `(i - min) % step = 0`.\n\nReturn value is based on a random 32-bit integer.\n\nIf `max >= 2^32`, will call `good.getInt()`, which goes up to\n2^53.\n\n__Arguments__\n\n* min - default=0. Returned integer will be min or greater.\n* max - default=2^32. Returned integer will be less than max.\n* step - default=1. Returned integer will be a multiple of this, counting from min.\n\n__Example__\n\n```javascript\nconsole.log(\"Rolling the dice:\");\nvar d1 = randy.randInt(1, 7);\nvar d2 = randy.randInt(1, 7);\nconsole.log(d1 + \" + \" + d2 + \" = \" + (d1 + d2));\nif (d1 + d2 == 2)\n    console.log(\"Snake eyes!\");\n```\n\n---------------------------------------\n\n<a name=\"choice\" />\n### choice (arr)\n\nReturns a randomly chosen element from the array arr.\n\nThrows an exception if arr is empty.\n\n__Arguments__\n\n* arr - Array of elements of any type.  Length > 0.  Return value will be an element of arr.\n\n__Example__\n\n```javascript\nvar breakfast = randy.choice([\"whisky\", \"bacon\", \"panic\"]);\nconsole.log(\"Good morning!  Enjoy some \" + breakfast + \"!\");\n```\n\n```javascript\n// Set direction vector for a ghost from Pac-Man.\nghost.currentDirection = randy.choice([\n    {x:0, y:-1}, {x:1, y:0}, {x:0, y:1}, {x:-1, y:0}\n]);\n```\n    \n---------------------------------------\n\n<a name=\"shuffle\" />\n### shuffle (arr)\n\nReturns a shuffled copy of arr.  Returned array contains the exact\nsame elements as arr, and equally many elements, but in a new order.\n\nUses the Fisher-Yates algorithm, aka the Knuth Shuffle.\n\n__Arguments__\n\n* arr - Array of elements of any type.\n\n__Example__\n\n```javascript\nvar runners = [\"Andy\", \"Bob\", \"Clarence\", \"David\"];\nvar startingOrder = randy.shuffle(runners);\n```\n\n---------------------------------------\n\n<a name=\"shuffleInplace\" />\n### shuffleInplace (arr)\n\nShuffles the array arr.  A more memory-efficient version of shuffle.\n\nUses the Fisher-Yates algorithm, aka the Knuth Shuffle.\n\n__Arguments__\n\n* arr - Array of elements of any type.  Will be modified.\n\n__Example__\n\n```javascript\n// Reorder elements at random until they happen to be sorted.\nfunction bogosort (arr) {\n    while (true) {\n        randy.shuffleInplace(arr);\n\n        var sorted = true;\n        for (var i=0; i<arr.length-1; i++)\n            sorted = sorted && (arr[i] < arr[i+1]);\n        if (sorted)\n            return;\n    }\n}\n```\n\n```javascript\n// Create new draw deck from card discard pile.\nif (deck.length == 0) {\n    deck = discardPile.splice(0);\n    randy.shuffleInplace(deck);\n}\n```\n\n---------------------------------------\n\n<a name=\"sample\" />\n### sample (population, count)\n\nReturns an array of length count, containing unique elements chosen\nfrom the array population.  Like a raffle draw.\n\nMathematically equivalent to `shuffle(population).slice(0, count)`, but\nmore efficient.  Catches fire if `count > population.length`.\n\n__Arguments__\n\n* population - Array of elements of any type.\n* count - How many elements to pick from array population.\n\n__Example__\n\n```javascript\n// Raffle draw for 3 bottles of wine.  Cindy has bought 2 tickets.\nvar raffleTickets = [\"Alice\", \"Beatrice\", \"Cindy\", \"Cindy\", \"Donna\"];\n\nvar winners = randy.sample(raffleTickets, 3);\n\nconsole.log(\"The winners are: \" + winners.join(\", \"));\n```\n\n---------------------------------------\n\n<a name=\"random\" />\n### random ()\n\nReturns a floating point number n, such that `0.0 <= n < 1.0`.\n\nExactly as `uniform()`, but provided for familiarity.\n\n---------------------------------------\n\n<a name=\"uniform\" />\n### uniform (min, max)\n### uniform (max)\n### uniform ()\n\nReturns a floating point number n, such that `min <= n < max`.\n\n__Arguments__\n\n* min - Default=0.0.  Returned value will be equal to or larger than this.\n* max - Default=1.0.  Returned value will be less than this.\n\n__Example__\n\n```javascript\n// Torpedo guidance system.\nvar heading = randy.uniform(360.0);\n```\n\n```javascript\n// Random event repeating every 1-5 minutes.\nfunction flashLightning () {\n    flash();\n    var delayNext = randy.uniform(1.0 * 60000, 5.0 * 60000);\n    setTimeout(flashLightning, delayNext);\n}\n```\n\n---------------------------------------\n\n<a name=\"triangular\" />\n### triangular (min, max, mode)\n### triangular (min, max)\n### triangular (max)\n### triangular ()\n\nThe triangular distribution is typically used as a subjective\ndescription of a population for which there is only limited sample\ndata, and especially in cases where the relationship between variables\nis known but data is scarce (possibly because of the high cost of\ncollection). It is based on a knowledge of the minimum and maximum and\nan \"inspired guess\" as to the modal value.\n\n[Wikipedia article](http://en.wikipedia.org/wiki/Triangular_distribution)\n\n__Arguments__\n\n* min - Default=0.0.  Returned value will be equal to or larger than this.\n* max - Default=1.0.  Returned value will be less than this.\n* mode - Default is average of min and max.  Returned values are likely to be close to this value.\n\n__Example__\n\n```javascript\n// Generate customer test data.  Customers are aged 18 to 40, but\n// most of them are in their twenties.  Their income is between\n// 40000-150000 Hyrulean Rupees per year, but typically around\n// 60000.\nfor (i=0; i<1000; i++) {\n    db.insertCustomer({\n        name: \"Bruce\",\n        birthYear: Math.floor( randy.triangular(1972, 1990, 1983) ),\n        income: randy.triangular(40000, 150000, 60000)\n    });\n}\n```\n\n---------------------------------------\n\n<a name=\"getRandBits\" />\n### getRandBits (n)\n\nReturns a random integer of bit width n, where `n <= 53`.\n\n__Arguments__\n\n* n - Number of random bits in return value.\n\n__Example__\n\n```javascript\n// A perfect distribution function, which rejects overflow values\n// instead of squeezing them into the desired range by use of modulo.\nfunction perfectInt (max) {\n    if (max == 0)\n        return 0;\n    var log2 = 0;\n    var mult = 1;\n    while (mult < max) {\n        log2 += 1;\n        mult *= 2;\n    }\n    while (false == false) {\n        var r = randy.getRandBits(log2);\n        if (r < max)\n            return r;\n    }\n}\n```\n\n---------------------------------------\n\n## State Functions\n\n<a name=\"getState\" />\n### getState ()\n\nReturns a JavaScript object representing the current state of the generator.\n\nThis object can be used as a parameter to `setState()`.\n\n<a name=\"setState\" />\n### setState (state)\n\nSets the generator to a specific state, allowing for replay of random values.\n\n__Arguments__\n\n* state - Must be object retrieved from an earlier call to `getState()`.\n\n__Example__\n\nThis will roll a pair of dice, reset the generator state, and roll the\ndice again with the exact same output.\n\n```javascript\nvar state = randy.getState();\nconsole.log(\"Rolling the dice:\");\nvar d1 = randy.randInt(1, 7);\nvar d2 = randy.randInt(1, 7);\nconsole.log(d1 + \" + \" + d2 + \" = \" + (d1 + d2));\n\nconsole.log(\"Instant replay:\");\nrandy.setState(state);\nd1 = randy.randInt(1, 7);\nd2 = randy.randInt(1, 7);\nconsole.log(d1 + \" + \" + d2 + \" = \" + (d1 + d2));\n```\n\n<a name=\"instance\" />\n### instance ()\n### instance (state)\n\nCreates a separate `randy` instance, for those use cases where a\nglobal object is a bad fit.  The instance has the same functions as\nthe global object.\n\nIf no `state` parameter is given, the new instance will be initialized\nrandomly.\n\nCalling this will not affect the generator state.\n\n__Arguments__\n\n* state - Must be object retrieved from an earlier call to `getState()`.\n\n__Example__\n\nCreate two instances, one a copy of the global object.  Sync the\ncopies to the original `randy` state.\n\n```javascript\nvar origState = randy.getState();\nvar r1 = randy.instance(origState);\nvar r2 = randy.instance();\nconsole.log(randy.randInt(50), r1.randInt(50), r2.randInt(50)); // 34 34 17\nconsole.log(randy.randInt(50), r1.randInt(50), r2.randInt(50)); // 12 12 4\nr1.setState(origState);\nr2.setState(origState);\nconsole.log(randy.randInt(50), r1.randInt(50), r2.randInt(50)); // 15 34 34\nconsole.log(randy.randInt(50), r1.randInt(50), r2.randInt(50)); // 36 12 12\n```\n\n---------------------------------------\n\n## Notes\n\nNo functions rely on `this`, so it's safe to e.g. assign\n`randy.good.randInt` to a variable or pass it around as a\nparameter.\n\nDue to floating point rounding, functions returning floating point\nvalues may *extremely rarely* tangent the upper bound.\n\nMaximum integer range is 2^53 = 9007199254740992.  This is the maximum\ninteger available in JavaScript without losing precision.  Any calls\nrequiring a larger range than this, explicitly or implicitly, will not\nyield correct results.\n","maintainers":[{"name":"deestan","email":"helge.holm@gmail.com"}],"time":{"modified":"2023-07-09T22:07:48.272Z","created":"2012-06-10T22:21:15.816Z","1.0.0alpha":"2012-06-10T22:21:19.226Z","1.0.0alpha2":"2012-06-11T23:31:52.202Z","1.0.0":"2012-06-15T22:41:20.213Z","1.1.0alpha":"2012-06-17T00:14:26.791Z","1.1.0beta":"2012-06-17T14:17:34.736Z","1.1.0":"2012-06-17T19:59:20.940Z","1.2.0alpha":"2012-06-18T21:56:49.525Z","1.1.1beta":"2012-06-19T09:48:25.896Z","1.1.1":"2012-06-19T09:56:04.666Z","1.2.0beta":"2012-06-19T09:58:43.117Z","1.2.0":"2012-06-21T21:46:11.846Z","1.3.0":"2012-07-04T15:01:16.704Z","1.3.1":"2012-10-05T09:28:27.403Z","1.4.0":"2012-10-12T14:20:42.157Z","1.4.1":"2013-03-17T15:06:04.780Z","1.4.2":"2013-04-12T10:13:17.621Z","1.4.3":"2014-03-13T17:31:38.073Z","1.5.0":"2014-05-24T01:35:54.333Z","1.5.1":"2014-05-24T03:41:05.598Z"},"author":{"name":"Helge Skogly Holm","email":"helge.holm@gmail.com"},"repository":{"type":"git","url":"http://github.com/deestan/randy.git"},"users":{"krampstudio":true,"sky3r":true,"flumpus-dev":true},"keywords":["random"],"bugs":{"url":"http://github.com/deestan/randy/issues","email":"helge.holm@gmail.com"},"readmeFilename":"README.md","license":"MIT"}