{"_id":"distributions-normal-random","_rev":"5-d1741125ca5e501241d3dd4e3afb0bc6","name":"distributions-normal-random","description":"Generates normally distributed random variates.","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.0":{"name":"distributions-normal-random","version":"0.0.0","description":"Generates normally distributed random variates.","author":{"name":"Philipp Burckhardt","email":"pburckhardt@outlook.com"},"contributors":[{"name":"Philipp Burckhardt","email":"pburckhardt@outlook.com"}],"scripts":{"test":"mocha","test-cov":"istanbul cover ./node_modules/.bin/_mocha --dir ./reports/coverage -- -R spec","codecov":"istanbul cover ./node_modules/.bin/_mocha --dir ./reports/codecov/coverage --report lcovonly -- -R spec && cat ./reports/codecov/coverage/lcov.info | codecov && rm -rf ./reports/codecov"},"main":"./lib","repository":{"type":"git","url":"git://github.com/distributions-io/normal-random.git"},"keywords":["distributions.io","distributions","probability","statistics","stats","array","arrays","matrix","matrices","fill","typed-array","dstructs","ndarray","multidimensional","random variables","random numbers","random variates","gaussian","bell-shaped"],"bugs":{"url":"https://github.com/distributions-io/normal-random/issues"},"dependencies":{"compute-array-constructors":"^1.0.0","compute-lcg":"^1.0.0","dstructs-matrix":"^2.0.0","validate.io-nonnegative":"^1.0.0","validate.io-object":"^1.0.4","validate.io-positive-integer":"^1.0.0","validate.io-positive-integer-array":"^1.0.0","validate.io-positive-primitive":"^1.0.0","validate.io-string-primitive":"^1.0.0"},"devDependencies":{"chai":"3.x.x","codecov.io":"^0.1.5","compute-mean":"^3.0.0","istanbul":"^0.3.0","jshint":"2.x.x","jshint-stylish":"2.x.x","mocha":"2.x.x"},"license":"MIT","gitHead":"0c303778c6c2f8724d97a7e5535cca0731697fc7","homepage":"https://github.com/distributions-io/normal-random#readme","_id":"distributions-normal-random@0.0.0","_shasum":"bc3563c4116d89806bf8f4acc85be137d5fe935c","_from":".","_npmVersion":"2.8.4","_nodeVersion":"4.0.0","_npmUser":{"name":"planeshifter","email":"pgb@andrew.cmu.edu"},"dist":{"shasum":"bc3563c4116d89806bf8f4acc85be137d5fe935c","tarball":"https://registry.npmjs.org/distributions-normal-random/-/distributions-normal-random-0.0.0.tgz","integrity":"sha512-/o0yLQXFFbMzRXQ6K0sxgE5i0y3yHLt4UDP2X8ltNaHd1d4NY+KbL3WMWndVc41T6goiKM4FT2sCgOsgWTUHGQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCMmtuB6v6W2jKr1PCV9cybJ+LFDKtEBDPqjPpXWIixDAIhAMsBk036TJAJBUspO9/LrKG1biGXK8tiYkwEjxNVUK6S"}]},"maintainers":[{"name":"planeshifter","email":"pgb@andrew.cmu.edu"}]},"0.0.1":{"name":"distributions-normal-random","version":"0.0.1","description":"Generates normally distributed random variates.","author":{"name":"Philipp Burckhardt","email":"pburckhardt@outlook.com"},"contributors":[{"name":"Philipp Burckhardt","email":"pburckhardt@outlook.com"}],"scripts":{"test":"mocha","test-cov":"istanbul cover ./node_modules/.bin/_mocha --dir ./reports/coverage -- -R spec","codecov":"istanbul cover ./node_modules/.bin/_mocha --dir ./reports/codecov/coverage --report lcovonly -- -R spec && cat ./reports/codecov/coverage/lcov.info | codecov && rm -rf ./reports/codecov"},"main":"./lib","repository":{"type":"git","url":"git://github.com/distributions-io/normal-random.git"},"keywords":["distributions.io","distributions","probability","statistics","stats","array","arrays","matrix","matrices","fill","typed-array","dstructs","ndarray","multidimensional","random variables","random numbers","random variates","gaussian","bell-shaped"],"bugs":{"url":"https://github.com/distributions-io/normal-random/issues"},"dependencies":{"compute-array-constructors":"^1.0.0","compute-lcg":"^1.0.0","dstructs-matrix":"^2.0.0","math-abs":"^1.0.2","math-exp":"^1.0.0","math-ln":"^1.0.0","math-power":"^1.0.0","math-sqrt":"^1.0.1","validate.io-nonnegative":"^1.0.0","validate.io-number-primitive":"^1.0.0","validate.io-object":"^1.0.4","validate.io-positive-integer":"^1.0.0","validate.io-positive-integer-array":"^1.0.0","validate.io-string-primitive":"^1.0.0"},"devDependencies":{"chai":"3.x.x","codecov.io":"^0.1.5","compute-mean":"^3.0.0","istanbul":"^0.3.0","jshint":"2.x.x","jshint-stylish":"2.x.x","mocha":"2.x.x"},"license":"MIT","gitHead":"4abd8aaf5078a8a5efa1e330bead7442326e30bf","homepage":"https://github.com/distributions-io/normal-random#readme","_id":"distributions-normal-random@0.0.1","_shasum":"04f554515f88df1b8b25df733d7323102e7e71dc","_from":".","_npmVersion":"3.3.12","_nodeVersion":"5.3.0","_npmUser":{"name":"planeshifter","email":"pgb@andrew.cmu.edu"},"dist":{"shasum":"04f554515f88df1b8b25df733d7323102e7e71dc","tarball":"https://registry.npmjs.org/distributions-normal-random/-/distributions-normal-random-0.0.1.tgz","integrity":"sha512-pB8vIJAPlic7+qWGXz5KLuAtxIaX+JmOrUQdZYMaRCfjaqSf5WbpKCRkAD7aSJCgk5XemOa4Wyd+JN0JXQHeSQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBmk9vsCkwSlgFznyTMO23puljhJsA53nH9jBJ58agn3AiBf94hcCB4lzIhOl7e+pK1eit5kuJDvDeR4bA9EXfmlgA=="}]},"maintainers":[{"name":"kgryte","email":"kgryte@gmail.com"},{"name":"planeshifter","email":"pgb@andrew.cmu.edu"}]}},"readme":"Normal Random Variables\n===\n[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][codecov-image]][codecov-url] [![Dependencies][dependencies-image]][dependencies-url]\n\n> Creates a [matrix](https://github.com/dstructs/matrix) or array filled with draws from a [normal distribution](https://en.wikipedia.org/wiki/Normal_distribution).\n\n\n## Installation\n\n``` bash\n$ npm install distributions-normal-random\n```\n\nFor use in the browser, use [browserify](https://github.com/substack/node-browserify).\n\n\n## Usage\n\n``` javascript\nvar random = require( 'distributions-normal-random' );\n```\n\n#### random( [dims][, opts] )\n\nCreates a [`matrix`](https://github.com/dstructs/matrix) or [`array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) filled with draws from a [normal distribution](https://en.wikipedia.org/wiki/Normal_distribution). The `dims` argument may either be a positive `integer` specifying a `length` or an `array` of positive `integers` specifying dimensions. If no `dims` argument is supplied,the function returns a single random draw from a [normal distribution](https://en.wikipedia.org/wiki/Normal_distribution).\n\n``` javascript\nvar out;\n\n// Set seed\nrandom.seed = 2;\n\nout = random( 5 );\n// returns [ ~-0.832, ~0.735, ~-1.432, ~0.057, -0.13 ]\n\nout = random( [2,1,2] );\n// returns [ [ [~0.969,~-0.394] ], [ [~0.599,~-1.511] ] ]\n\n```\n\nThe function accepts the following `options`:\n\n*\t__mu__: mean parameter. Default: `0`.\n*\t__sigma__: standard deviation. Default: `1`.\n*\t__seed__: positive integer used as a seed to initialize the generator. If not supplied, uniformly distributed random numbers are generated via an underlying generator seedable by setting the `seed` property of the exported function.\n*\t__dtype__: output data type (see [`matrix`](https://github.com/dstructs/matrix) for a list of acceptable data types). Default: `generic`.\n\nThe [normal](https://en.wikipedia.org/wiki/Normal_distribution) distribution is a function of two parameters: `mu`(mean) and `sigma > 0`(standard deviation). By default, `mu` is equal to `0` and `sigma` is equal to `1`. To adjust either parameter, set the corresponding option.\n\n``` javascript\nvar out = random( 5, {\n\t'mu': 20,\n\t'sigma': 4,\n});\n// returns [ ~25.293, ~21.105, ~21.347, 22.57, ~18.726 ]\n\n```\n\nTo be able to reproduce the generated random numbers, set the `seed` option to a positive integer.\n\n``` javascript\nvar out = random( 3, {\n\t'seed': 22\n});\n// returns [ ~-0.643, ~0.937, ~0.049 ]\n\nvar out = random( 3, {\n    'seed': 22\n});\n// returns [ ~-0.643, ~0.937, ~0.049 ]\n\n```\n\nIf no `seed` option is supplied, each function call uses a common underlying uniform number generator. A positive-integer seed for this underlying generator can be supplied by setting the seed property of the exported function.\n\n```javascript\nrandom.seed = 11;\nvar out = random();\n// returns ~-0.921\n\nvar out = random();\n// returns ~0.389\n\nrandom.seed = 11;\nvar out = random();\n// returns ~-0.921\n\nvar out = random();\n// returns ~0.389\n\n```\n\nBy default, the output data structure is a generic [`array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array). To output a [`typed array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays) or [`matrix`](https://github.com/dstructs/matrix), set the `dtype` option.\n\n``` javascript\nvar out;\n\nout = random( 5, {\n\t'dtype': 'float32'\n});\n// returns Float32Array( [~0.166,~0.916,~-0.003,-0.08,~-2.608] )\n\nout = random( [3,2], {\n\t'dtype': 'float64'\n});\n/*\n\t[ ~-0.482 ~0.274\n\t  ~0.725 ~1.113\n\t  ~0.608 1.05 ]\n*/\n\n```\n\n__Notes__:\n*\tCurrently, for more than `2` dimensions, the function outputs a __generic__ `array` and ignores any specified `dtype`.\n\n\t``` javascript\n\tvar out = random( [2,1,3], {\n\t\t'dtype': 'float32'\n\t});\n\t// returns [ [ [~0.873,~-0.510,~-0.370] ], [ [~0.393,~-0.233,~0.907] ] ]\n\n\t```\n\n## Method\n\nThe used algorithm to generate normal random variables is the \"Improved Ziggurat method\" developed by J. Doornik. In a speed comparison of different algorithms, Doornik found that the Ziggurat method was two or three times faster than the commonly used polar method ([Box-Mueller Transform](https://en.wikipedia.org/wiki/Box-Muller_transform)) when generating `10^9` standard normal random numbers.\n\nReference:\n> Doornik, J. a. (2005).\n> An Improved Ziggurat Method to Generate Normal Random Samples.\n\n\n## Examples\n\n``` javascript\nvar random = require( 'distributions-normal-random' ),\n\tout;\n\n// Set seed\nrandom.seed = 11;\n\n// Plain arrays...\n\n// 1x10:\nout = random( 10 );\n\n// 2x1x3:\nout = random( [2,1,3] );\n\n// 5x5x5:\nout = random( [5,5,5] );\n\n// 10x5x10x20:\nout = random( [10,5,10,20] );\n\n// Typed arrays...\nout = random( 10, {\n\t'dtype': 'float32'\n});\n\n// Matrices...\nout = random( [3,2], {\n\t'dtype': 'float64'\n});\n```\n\nTo run the example code from the top-level application directory,\n\n``` bash\n$ node ./examples/index.js\n```\n\n\n## Tests\n\n### Unit\n\nUnit tests use the [Mocha](http://mochajs.org/) test framework with [Chai](http://chaijs.com) assertions. To run the tests, execute the following command in the top-level application directory:\n\n``` bash\n$ make test\n```\n\nAll new feature development should have corresponding unit tests to validate correct functionality.\n\n\n### Test Coverage\n\nThis repository uses [Istanbul](https://github.com/gotwarlost/istanbul) as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:\n\n``` bash\n$ make test-cov\n```\n\nIstanbul creates a `./reports/coverage` directory. To access an HTML version of the report,\n\n``` bash\n$ make view-cov\n```\n\n\n---\n## License\n\n[MIT license](http://opensource.org/licenses/MIT).\n\n\n## Copyright\n\nCopyright &copy; 2015-2016. The [Compute.io](https://github.com/compute-io) Authors.\n\n\n[npm-image]: http://img.shields.io/npm/v/distributions-normal-random.svg\n[npm-url]: https://npmjs.org/package/distributions-normal-random\n\n[travis-image]: http://img.shields.io/travis/distributions-io/normal-random/master.svg\n[travis-url]: https://travis-ci.org/distributions-io/normal-random\n\n[codecov-image]: https://img.shields.io/codecov/c/github/distributions-io/normal-random/master.svg\n[codecov-url]: https://codecov.io/github/distributions-io/normal-random?branch=master\n\n[dependencies-image]: http://img.shields.io/david/distributions-io/normal-random.svg\n[dependencies-url]: https://david-dm.org/distributions-io/normal-random\n\n[dev-dependencies-image]: http://img.shields.io/david/dev/distributions-io/normal-random.svg\n[dev-dependencies-url]: https://david-dm.org/dev/distributions-io/normal-random\n\n[github-issues-image]: http://img.shields.io/github/issues/distributions-io/normal-random.svg\n[github-issues-url]: https://github.com/distributions-io/normal-random/issues\n","maintainers":[{"name":"kgryte","email":"kgryte@gmail.com"},{"name":"planeshifter","email":"pgb@andrew.cmu.edu"}],"time":{"modified":"2022-06-15T05:26:49.350Z","created":"2015-11-05T04:29:58.082Z","0.0.0":"2015-11-05T04:29:58.082Z","0.0.1":"2016-01-27T03:28:41.146Z"},"homepage":"https://github.com/distributions-io/normal-random#readme","keywords":["distributions.io","distributions","probability","statistics","stats","array","arrays","matrix","matrices","fill","typed-array","dstructs","ndarray","multidimensional","random variables","random numbers","random variates","gaussian","bell-shaped"],"repository":{"type":"git","url":"git://github.com/distributions-io/normal-random.git"},"contributors":[{"name":"Philipp Burckhardt","email":"pburckhardt@outlook.com"}],"author":{"name":"Philipp Burckhardt","email":"pburckhardt@outlook.com"},"bugs":{"url":"https://github.com/distributions-io/normal-random/issues"},"license":"MIT","readmeFilename":"README.md"}