{"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","tarball":"http://registry-npm.ywwl.com/xorshift/download/xorshift-0.2.1.tgz","integrity":"sha512-P7vgjXF9fGNdj97iI5v9nMnh1RpUROBlbfITf5CTAhaz96h/vKI/Lo5nikVqE0pBvraYNjdPIyOfHmECh7Mxxg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDcD2f4vNfmZiMP+4CibBd7DWStJzUBDEJgeR1nlMIdHQIgAdFR3XZoFOU1TuaJSbb68LDtrpjLszlLOF/Q/RJM2Ew="}],"size":10703,"noattachment":false,"key":"/xorshift/-/xorshift-0.2.1.tgz"},"maintainers":[{"name":"andreasmadsen","email":"amwebdk@gmail.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/xorshift-0.2.1.tgz_1474715744000_0.49601434567011893"},"directories":{},"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","publish_time":1474715745239,"_cnpm_publish_time":1474715745239,"dist-tags":{"latest":"1.2.0"}}