{"_id":"xorshift","_rev":"534681","name":"xorshift","description":"Random number generator using xorshift128+","dist-tags":{"latest":"1.2.0"},"maintainers":[{"name":"andreasmadsen","email":""}],"time":{"modified":"2021-08-13T20:25:46.000Z","created":"2014-11-15T19:02:08.317Z","1.2.0":"2021-08-13T20:22:57.738Z","1.1.1":"2017-10-17T11:42:50.233Z","1.1.0":"2017-07-09T04:11:15.289Z","1.0.0":"2016-09-24T11:29:18.139Z","0.2.1":"2016-09-24T11:15:45.239Z","0.2.0":"2014-11-23T12:04:42.942Z","0.1.0":"2014-11-15T19:02:08.317Z"},"users":{"dzhou777":true,"moimikey":true,"shanewholloway":true},"author":{"name":"Andreas Madsen","email":"amwebdk@gmail.com"},"repository":{"type":"git","url":"git://github.com/AndreasMadsen/xorshift.git"},"versions":{"1.2.0":{"name":"xorshift","description":"Random number generator using xorshift128+","version":"1.2.0","author":{"name":"Andreas Madsen","email":"amwebdk@gmail.com"},"contributors":[{"name":"Emil Bay","email":"github@tixz.dk"}],"main":"./xorshift.js","scripts":{"test":"tap test.js","benchmark":"node ./benchmark.js"},"repository":{"type":"git","url":"git://github.com/AndreasMadsen/xorshift.git"},"keywords":["random","rng","xorshift"],"devDependencies":{"tap":"0.4.x"},"license":"MIT","gitHead":"741f76a721d236963760f78e536a7a13d1403e88","bugs":{"url":"https://github.com/AndreasMadsen/xorshift/issues"},"homepage":"https://github.com/AndreasMadsen/xorshift#readme","_id":"xorshift@1.2.0","_nodeVersion":"16.2.0","_npmVersion":"7.13.0","dist":{"shasum":"30a4cdd8e9f8d09d959ed2a88c42a09c660e8148","size":10581,"noattachment":false,"key":"/xorshift/-/xorshift-1.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/xorshift/download/xorshift-1.2.0.tgz"},"_npmUser":{"name":"andreasmadsen","email":"amwebdk@gmail.com"},"directories":{},"maintainers":[{"name":"andreasmadsen","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/xorshift_1.2.0_1628886177595_0.45463588003037114"},"_hasShrinkwrap":false,"publish_time":1628886177738,"_cnpm_publish_time":1628886177738},"1.1.1":{"name":"xorshift","description":"Random number generator using xorshift128+","version":"1.1.1","author":{"name":"Andreas Madsen","email":"amwebdk@gmail.com"},"contributors":[{"name":"Emil Bay","email":"github@tixz.dk"}],"main":"./xorshift.js","scripts":{"test":"tap test.js","benchmark":"node ./benchmark.js"},"repository":{"type":"git","url":"git://github.com/AndreasMadsen/xorshift.git"},"keywords":["random","rng","xorshift"],"devDependencies":{"tap":"0.4.x"},"license":"MIT","gitHead":"94c1a5e8d64b7f632d620137e3cd17e1fd49664e","bugs":{"url":"https://github.com/AndreasMadsen/xorshift/issues"},"homepage":"https://github.com/AndreasMadsen/xorshift#readme","_id":"xorshift@1.1.1","_npmVersion":"5.3.0","_nodeVersion":"9.0.0-pre","_npmUser":{"name":"andreasmadsen","email":"amwebdk@gmail.com"},"dist":{"shasum":"fb85883a82a0625c9f11372205df75b67dfe53e0","size":10481,"noattachment":false,"key":"/xorshift/-/xorshift-1.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/xorshift/download/xorshift-1.1.1.tgz"},"maintainers":[{"name":"andreasmadsen","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/xorshift-1.1.1.tgz_1508240569238_0.27366448612883687"},"directories":{},"publish_time":1508240570233,"_hasShrinkwrap":false,"_cnpm_publish_time":1508240570233},"1.1.0":{"name":"xorshift","description":"Random number generator using xorshift128+","version":"1.1.0","author":{"name":"Andreas Madsen","email":"amwebdk@gmail.com"},"contributors":[{"name":"Emil Bay","email":"github@tixz.dk"}],"main":"./xorshift.js","scripts":{"test":"tap test.js","benchmark":"node ./benchmark.js"},"repository":{"type":"git","url":"git://github.com/AndreasMadsen/xorshift.git"},"keywords":["random","rng","xorshift"],"devDependencies":{"tap":"0.4.x"},"license":"MIT","gitHead":"e31b879d16dad33dd8a238729dadd27f801e0284","bugs":{"url":"https://github.com/AndreasMadsen/xorshift/issues"},"homepage":"https://github.com/AndreasMadsen/xorshift#readme","_id":"xorshift@1.1.0","_npmVersion":"5.0.3","_nodeVersion":"9.0.0-pre","_npmUser":{"name":"andreasmadsen","email":"amwebdk@gmail.com"},"dist":{"shasum":"862e98147cb58136f55c7baebbda9c8474a1430f","size":10628,"noattachment":false,"key":"/xorshift/-/xorshift-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/xorshift/download/xorshift-1.1.0.tgz"},"maintainers":[{"name":"andreasmadsen","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/xorshift-1.1.0.tgz_1499573474248_0.8265900542028248"},"directories":{},"publish_time":1499573475289,"_cnpm_publish_time":1499573475289,"_hasShrinkwrap":false},"1.0.0":{"name":"xorshift","description":"Random number generator using xorshift128+","version":"1.0.0","author":{"name":"Andreas Madsen","email":"amwebdk@gmail.com"},"contributors":[{"name":"Emil Bay","email":"github@tixz.dk"}],"main":"./xorshift.js","scripts":{"test":"tap test.js","benchmark":"node ./benchmark.js"},"repository":{"type":"git","url":"git://github.com/AndreasMadsen/xorshift.git"},"keywords":["random","rng","xorshift"],"devDependencies":{"tap":"0.4.x"},"license":"MIT","gitHead":"821e6c2338bd41ae9ea60d3bbb307158ded1b721","bugs":{"url":"https://github.com/AndreasMadsen/xorshift/issues"},"homepage":"https://github.com/AndreasMadsen/xorshift#readme","_id":"xorshift@1.0.0","_shasum":"1d256c2276a235252e5c94f91688f3fb99f4eb61","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.3.2-pre","_npmUser":{"name":"andreasmadsen","email":"amwebdk@gmail.com"},"dist":{"shasum":"1d256c2276a235252e5c94f91688f3fb99f4eb61","size":10714,"noattachment":false,"key":"/xorshift/-/xorshift-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/xorshift/download/xorshift-1.0.0.tgz"},"maintainers":[{"name":"andreasmadsen","email":""}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/xorshift-1.0.0.tgz_1474716556908_0.466318323276937"},"directories":{},"publish_time":1474716558139,"_cnpm_publish_time":1474716558139,"_hasShrinkwrap":false},"0.2.1":{"name":"xorshift","description":"Random number generator using xorshift128+","version":"0.2.1","author":{"name":"Andreas Madsen","email":"amwebdk@gmail.com"},"contributors":[{"name":"Emil Bay","email":"github@tixz.dk"}],"main":"./xorshift.js","scripts":{"test":"tap test.js","benchmark":"node ./benchmark.js"},"repository":{"type":"git","url":"git://github.com/AndreasMadsen/xorshift.git"},"keywords":["random","rng","xorshift"],"devDependencies":{"tap":"0.4.x"},"license":"MIT","gitHead":"ed9e7dab23d9b23688601bee033cbaed47185c59","bugs":{"url":"https://github.com/AndreasMadsen/xorshift/issues"},"homepage":"https://github.com/AndreasMadsen/xorshift#readme","_id":"xorshift@0.2.1","_shasum":"fcd82267e9351c13f0fb9c73307f25331d29c63a","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.3.2-pre","_npmUser":{"name":"andreasmadsen","email":"amwebdk@gmail.com"},"dist":{"shasum":"fcd82267e9351c13f0fb9c73307f25331d29c63a","size":10703,"noattachment":false,"key":"/xorshift/-/xorshift-0.2.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/xorshift/download/xorshift-0.2.1.tgz"},"maintainers":[{"name":"andreasmadsen","email":""}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/xorshift-0.2.1.tgz_1474715744000_0.49601434567011893"},"directories":{},"publish_time":1474715745239,"_cnpm_publish_time":1474715745239,"_hasShrinkwrap":false},"0.2.0":{"name":"xorshift","description":"Random number generator using xorshift128+","version":"0.2.0","author":{"name":"Andreas Madsen","email":"amwebdk@gmail.com"},"contributors":[{"name":"Emil Bay","email":"github@tixz.dk"}],"main":"./xorshift.js","scripts":{"test":"tap test.js","benchmark":"node ./benchmark.js"},"repository":{"type":"git","url":"git://github.com/AndreasMadsen/xorshift.git"},"keywords":["random","rng","xorshift"],"devDependencies":{"tap":"0.4.x"},"license":"MIT","gitHead":"9063622a4c2150004e70cb4eeeea0d8a20704a7d","bugs":{"url":"https://github.com/AndreasMadsen/xorshift/issues"},"homepage":"https://github.com/AndreasMadsen/xorshift","_id":"xorshift@0.2.0","_shasum":"9725e6bacca7fb9e96ad9dfd5be05174db1ebb2a","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"andreasmadsen","email":"amwebdk@gmail.com"},"maintainers":[{"name":"andreasmadsen","email":""}],"dist":{"shasum":"9725e6bacca7fb9e96ad9dfd5be05174db1ebb2a","size":7437,"noattachment":false,"key":"/xorshift/-/xorshift-0.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/xorshift/download/xorshift-0.2.0.tgz"},"directories":{},"publish_time":1416744282942,"_cnpm_publish_time":1416744282942,"_hasShrinkwrap":false},"0.1.0":{"name":"xorshift","description":"Random number generator using xorshift","version":"0.1.0","author":{"name":"Andreas Madsen","email":"amwebdk@gmail.com"},"main":"./xorshift.js","scripts":{"test":"tap test.js"},"repository":{"type":"git","url":"git://github.com/AndreasMadsen/xorshift.git"},"keywords":["random","rng","xorshift"],"devDependencies":{"tap":"0.4.x"},"license":"MIT","gitHead":"ee76b010e3243405790d59c38416349378dd6ea4","bugs":{"url":"https://github.com/AndreasMadsen/xorshift/issues"},"homepage":"https://github.com/AndreasMadsen/xorshift","_id":"xorshift@0.1.0","_shasum":"3a5a82780d1cfca40d24e57577e6a0c0861d2de9","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"andreasmadsen","email":"amwebdk@gmail.com"},"maintainers":[{"name":"andreasmadsen","email":""}],"dist":{"shasum":"3a5a82780d1cfca40d24e57577e6a0c0861d2de9","size":2472,"noattachment":false,"key":"/xorshift/-/xorshift-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/xorshift/download/xorshift-0.1.0.tgz"},"directories":{},"publish_time":1416078128317,"_cnpm_publish_time":1416078128317,"_hasShrinkwrap":false}},"readme":"# xorshift [![Build Status](https://travis-ci.org/AndreasMadsen/xorshift.svg?branch=master)](https://travis-ci.org/AndreasMadsen/xorshift)\n\n> Pseudorandom number generator using [xorshift128+](http://xorshift.di.unimi.it/)\n\n## Installation\n\n```bash\nnpm install xorshift\n```\n\n## Example\n\n```javascript\nvar xorshift = require('xorshift');\n\nfor (var i = 0; i < 10; i++) {\n  console.log(xorshift.random()); // number in range [0, 1)\n}\n```\n\n## Documentation\n\nThis module exports a default pseudo random generator. This generators seed have\nalready been set (using `Date.now()`). If this is not suitable a custom\ngenerator can be initialized using the constructor function\n`xorshift.constructor`. In both cases random numbers can be generated using\nthe two methods `.random` and `.randomint`.\n\n```javascript\nvar xorshift = require('xorshift');\n```\n\n### xorshift.random()\n\nThis method returns a random 64-bit double, with its value in the range [0, 1).\nThat means 0 is inclusive and 1 is exclusive. This is equivalent to\n`Math.random()`.\n\n```javascript\nconsole.log(xorshift.random()); // number between 0 and 1\n```\n\nThis method will serve most purposes, for instance to randomly select between\n2, 3 and 4, this function can be used:\n\n```javascript\nfunction uniformint(a, b) {\n  return Math.floor(a + xorshift().random() * (b - a));\n}\n\nconsole.log(uniformint(2, 4));\n```\n\n### xorshift.randomint()\n\nThis method returns a random 64-bit integer. Since JavaScript doesn't support\n64-bit integers, the number is represented as an array with two elements in\nbig-endian order.\n\nThis method is useful if high precision is required, the `xorshift.random()`\nmethod won't allow you to get this precision since a 64-bit IEEE754 double\nonly contains the 52 most significant bits.\n\n```javascript\nvar bview = require('binary-view');\nconsole.log(bview( new Uint32Array(xorshift.randomint()) ));\n```\n\n### xorshift.constructor\n\nThis method is used to construct a new random generator, with a specific seed.\nThis is useful when testing software where random numbers are involved and\ngetting consistent results is important.\n\n```javascript\nvar XorShift = require('xorshift').constructor;\nvar rng1 = new XorShift([1, 0, 2, 0]);\nvar rng2 = new XorShift([1, 0, 2, 0]);\n\nassert(rng1.random() === rng2.random());\n```\n\nA `XorShift` instance have both methods `random` and `randomint`. In fact the\n`xorshift` module is an instance of the `XorShift` constructor.\n\nThe constructor can also be accessed as `require('xorshift').XorShift`, which\nis useful when using the `import` syntax.\n\n```javascript\nimport { XorShift } from 'xorshift'\n```\n\n## Reference\n\nThis module implements the xorshift128+ pseudo random number generator.\n\n> This is the fastest generator passing BigCrush without systematic\n> errors, but due to the relatively short period it is acceptable only\n> for applications with a very mild amount of parallelism; otherwise, use\n> a xorshift1024* generator.\n> – <cite> http://xorshift.di.unimi.it </cite>\n\nThis source also has a\n[reference implementation](http://xorshift.di.unimi.it/xorshift128plus.c)\nfor the xorshift128+ generator. A wrapper around this implementation has been\ncreated and is used for testing this module. To compile and run it:\n\n```shell\ngcc -O2 reference.c -o reference\n./reference <numbers> <seed0> <seed1>\n```\n\n* `<numbers>` can be any number greater than zero, and it will be the number\nof random numbers written to `stdout`. The default value is `10`.\n* `<seed0>` and `<seed1>` forms the 128bit seed that the algorithm uses. Default\nis `[1, 2]`.\n\n## License\n\n**This software is licensed under \"MIT\"**\n\n> Copyright (c) 2014 Andreas Madsen & Emil Bay\n>\n> Permission is hereby granted, free of charge, to any person obtaining a copy\n> of this software and associated documentation files (the \"Software\"), to deal\n> in the Software without restriction, including without limitation the rights\n> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n> copies of the Software, and to permit persons to whom the Software is\n> furnished to do so, subject to the following conditions:\n>\n> The above copyright notice and this permission notice shall be included in\n> all copies or substantial portions of the Software.\n>\n> THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n> THE SOFTWARE.\n","_attachments":{},"homepage":"https://github.com/AndreasMadsen/xorshift#readme","bugs":{"url":"https://github.com/AndreasMadsen/xorshift/issues"},"license":"MIT"}