{"_id":"distributions-rayleigh-pdf","_rev":"5-7383262ea0e115569d9a2c3e02eb9efd","name":"distributions-rayleigh-pdf","description":"Rayleigh distribution probability density function (PDF)","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.0":{"name":"distributions-rayleigh-pdf","version":"0.0.0","description":"Rayleigh distribution probability density function (PDF)","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","coveralls":"istanbul cover ./node_modules/.bin/_mocha --dir ./reports/coveralls/coverage --report lcovonly -- -R spec && cat ./reports/coveralls/coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./reports/coveralls"},"main":"./lib","repository":{"type":"git","url":"git://github.com/distributions-io/rayleigh-pdf.git"},"keywords":["distributions.io","distributions","probability","statistics","stats","pdf","exponential family","continuous distribution"],"bugs":{"url":"https://github.com/distributions-io/rayleigh-pdf/issues"},"dependencies":{"compute-array-constructors":"^1.0.0","dstructs-matrix":"^2.0.0","utils-deep-get":"^1.0.0","utils-deep-set":"^1.0.1","validate.io-array-like":"^1.0.1","validate.io-boolean-primitive":"^1.0.0","validate.io-function":"^1.0.2","validate.io-matrix-like":"^1.0.2","validate.io-nan":"^1.0.3","validate.io-nonnegative-integer":"^1.0.0","validate.io-number-primitive":"^1.0.0","validate.io-object":"^1.0.4","validate.io-positive-primitive":"^1.0.0","validate.io-string-primitive":"^1.0.0","validate.io-typed-array-like":"^1.0.0"},"devDependencies":{"chai":"3.x.x","mocha":"2.x.x","coveralls":"^2.11.1","istanbul":"^0.3.0","jshint":"2.x.x","jshint-stylish":"2.x.x","validate.io-finite":"^1.0.0"},"license":"MIT","gitHead":"75743596228282d1b3f8ba6cc69461681c40beb2","homepage":"https://github.com/distributions-io/rayleigh-pdf#readme","_id":"distributions-rayleigh-pdf@0.0.0","_shasum":"b7234ba7727e64cc10d9f6115d7d521e792ab068","_from":".","_npmVersion":"2.8.4","_nodeVersion":"4.0.0","_npmUser":{"name":"planeshifter","email":"pgb@andrew.cmu.edu"},"dist":{"shasum":"b7234ba7727e64cc10d9f6115d7d521e792ab068","tarball":"https://registry.npmjs.org/distributions-rayleigh-pdf/-/distributions-rayleigh-pdf-0.0.0.tgz","integrity":"sha512-Bxs8NVOZrKQAvu3jxJ6WzaLcDexbeUZ07l1ecmwqp4f61GrVGuM9NgUxTXiziWL5qwv94jeuEe2jvILC9BvS3g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCID4x3BlTX+H56afkwZq1IoHFDNrIQyFdytYH273pw8qXAiA/o+WzJoQBt+bTKWb99v8j2Gyx79zD9l02R1e6Giocmg=="}]},"maintainers":[{"name":"planeshifter","email":"pgb@andrew.cmu.edu"}]},"0.0.1":{"name":"distributions-rayleigh-pdf","version":"0.0.1","description":"Rayleigh distribution probability density function (PDF)","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","coveralls":"istanbul cover ./node_modules/.bin/_mocha --dir ./reports/coveralls/coverage --report lcovonly -- -R spec && cat ./reports/coveralls/coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./reports/coveralls"},"main":"./lib","repository":{"type":"git","url":"git://github.com/distributions-io/rayleigh-pdf.git"},"keywords":["distributions.io","distributions","probability","statistics","stats","pdf","exponential family","continuous distribution"],"bugs":{"url":"https://github.com/distributions-io/rayleigh-pdf/issues"},"dependencies":{"compute-array-constructors":"^1.0.0","dstructs-matrix":"^2.0.0","utils-deep-get":"^1.0.0","utils-deep-set":"^1.0.1","validate.io-array-like":"^1.0.1","validate.io-boolean-primitive":"^1.0.0","validate.io-function":"^1.0.2","validate.io-matrix-like":"^1.0.2","validate.io-nan":"^1.0.3","validate.io-nonnegative-integer":"^1.0.0","validate.io-number-primitive":"^1.0.0","validate.io-object":"^1.0.4","validate.io-positive-primitive":"^1.0.0","validate.io-string-primitive":"^1.0.0","validate.io-typed-array-like":"^1.0.0"},"devDependencies":{"chai":"3.x.x","mocha":"2.x.x","codecov.io":"^0.1.5","istanbul":"^0.3.0","jshint":"2.x.x","jshint-stylish":"2.x.x","validate.io-finite":"^1.0.0"},"license":"MIT","gitHead":"d130d65c7fbcfed3c7c031156526b108e50177f9","homepage":"https://github.com/distributions-io/rayleigh-pdf#readme","_id":"distributions-rayleigh-pdf@0.0.1","_shasum":"2d84d06ee43295d3005aae1b0aa256e1d65f7a2b","_from":".","_npmVersion":"2.8.4","_nodeVersion":"4.0.0","_npmUser":{"name":"planeshifter","email":"pgb@andrew.cmu.edu"},"dist":{"shasum":"2d84d06ee43295d3005aae1b0aa256e1d65f7a2b","tarball":"https://registry.npmjs.org/distributions-rayleigh-pdf/-/distributions-rayleigh-pdf-0.0.1.tgz","integrity":"sha512-WJcHhVIBc5vALmNbm1O1ykSOwohcVrd3odkDuOljyp/iPOS6JYbGfT9IKecLYSx1w0eo1mxEAF6pgKobC97SAQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFLjxc6tNjrBC5aCJLbkOxKtDU8TIbFQoaLFXXzxqdPXAiBwWhsjUqrkO+mrZnBeM4h03YxMBSwPinHjuO5/QUNliQ=="}]},"maintainers":[{"name":"kgryte","email":"kgryte@gmail.com"},{"name":"planeshifter","email":"pgb@andrew.cmu.edu"}]}},"readme":"Probability Density Function\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> [Rayleigh](https://en.wikipedia.org/wiki/Rayleigh_distribution) distribution probability density function (PDF).\n\nThe [probability density function](https://en.wikipedia.org/wiki/Probability_density_function) (PDF) for a [Rayleigh](https://en.wikipedia.org/wiki/Rayleigh_distribution) random variable is\n\n<div class=\"equation\" align=\"center\" data-raw-text=\"f(x;\\sigma) = \\begin{cases} \\frac{x}{\\sigma^2} e^{-x^2/(2\\sigma^2)} &amp; \\text{ for } x \\ge 0 \\\\\n0 & \\text{ otherwise } \\end{cases}\" data-equation=\"eq:pdf_function\">\n\t<img src=\"https://cdn.rawgit.com/distributions-io/rayleigh-pdf/97dabc8f55ecc2e50ffa8143a259d2c6fe551109/docs/img/eqn.svg\" alt=\"Probability density function (PDF) for a Rayleigh distribution.\">\n\t<br>\n</div>\n\nwhere `sigma` is the scale parameter.\n\n## Installation\n\n``` bash\n$ npm install distributions-rayleigh-pdf\n```\n\nFor use in the browser, use [browserify](https://github.com/substack/node-browserify).\n\n\n## Usage\n\n``` javascript\nvar pdf = require( 'distributions-rayleigh-pdf' );\n```\n\n#### pdf( x[, options] )\n\nEvaluates the [probability density function](https://en.wikipedia.org/wiki/Probability_density_function) (PDF) for the [Rayleigh](https://en.wikipedia.org/wiki/Rayleigh_distribution) distribution. `x` may be either a [`number`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number), an [`array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array), a [`typed array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays), or a [`matrix`](https://github.com/dstructs/matrix).\n\n``` javascript\nvar matrix = require( 'dstructs-matrix' ),\n\tmat,\n\tout,\n\tx,\n\ti;\n\nout = pdf( 1 );\n// returns ~0.607\n\nout = pdf( -1 );\n// returns 0\n\nx = [ 0, 0.5, 1, 1.5, 2, 2.5 ];\nout = pdf( x );\n// returns [ 0, ~0.441, ~0.607, ~0.487, ~0.271, ~0.11 ]\n\nx = new Int8Array( x );\nout = pdf( x );\n// returns Float64Array( [0,0,~0.607,~0.607,~0.271,~0.271] )\n\nx = new Float32Array( 6 );\nfor ( i = 0; i < 6; i++ ) {\n\tx[ i ] = i * 0.5;\n}\nmat = matrix( x, [3,2], 'float32' );\n/*\n\t[ 0  0.5\n\t  1  1.5\n\t  2  2.5 ]\n*/\n\nout = pdf( mat );\n/*\n\t[ 0     ~0.441\n\t ~0.607 ~0.487\n\t ~0.271 ~0.11 ]\n*/\n```\n\nThe function accepts the following `options`:\n\n*\t__sigma__: scale parameter. Default: `1`.\n* \t__accessor__: accessor `function` for accessing `array` values.\n* \t__dtype__: output [`typed array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays) or [`matrix`](https://github.com/dstructs/matrix) data type. Default: `float64`.\n*\t__copy__: `boolean` indicating if the `function` should return a new data structure. Default: `true`.\n*\t__path__: [deepget](https://github.com/kgryte/utils-deep-get)/[deepset](https://github.com/kgryte/utils-deep-set) key path.\n*\t__sep__: [deepget](https://github.com/kgryte/utils-deep-get)/[deepset](https://github.com/kgryte/utils-deep-set) key path separator. Default: `'.'`.\n\nA [Rayleigh](https://en.wikipedia.org/wiki/Rayleigh_distribution) distribution is a function of one parameter: `sigma`(scale parameter). By default, `sigma` is equal to `1`. To adjust it, set the corresponding option.\n\n``` javascript\nvar x = [ 0, 0.5, 1, 1.5, 2, 2.5 ];\n\nvar out = pdf( x, {\n\t'sigma': 3\n});\n// returns [ 0, ~0.0548, ~0.105, ~0.147, ~0.178, ~0.196 ]\n```\n\nFor non-numeric `arrays`, provide an accessor `function` for accessing `array` values.\n\n``` javascript\nvar data = [\n\t[0,0],\n\t[1,0.5],\n\t[2,1],\n\t[3,1.5],\n\t[4,2],\n\t[5,2.5]\n];\n\nfunction getValue( d, i ) {\n\treturn d[ 1 ];\n}\n\nvar out = pdf( data, {\n\t'accessor': getValue\n});\n// returns [ 0, ~0.441, ~0.607, ~0.487, ~0.271, ~0.11 ]\n```\n\n\nTo [deepset](https://github.com/kgryte/utils-deep-set) an object `array`, provide a key path and, optionally, a key path separator.\n\n``` javascript\nvar data = [\n\t{'x':[0,0]},\n\t{'x':[1,0.5]},\n\t{'x':[2,1]},\n\t{'x':[3,1.5]},\n\t{'x':[4,2]},\n\t{'x':[5,2.5]}\n];\n\nvar out = pdf( data, {\n\t'path': 'x/1',\n\t'sep': '/'\n});\n/*\n\t[\n\t\t{'x':[0,0]},\n\t\t{'x':[1,~0.441]},\n\t\t{'x':[2,~0.607]},\n\t\t{'x':[3,~0.487]},\n\t\t{'x':[4,~0.271]},\n\t\t{'x':[5,~0.11]}\n\t]\n*/\n\nvar bool = ( data === out );\n// returns true\n```\n\nBy default, when provided a [`typed array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays) or [`matrix`](https://github.com/dstructs/matrix), the output data structure is `float64` in order to preserve precision. To specify a different data type, set the `dtype` option (see [`matrix`](https://github.com/dstructs/matrix) for a list of acceptable data types).\n\n``` javascript\nvar x, out;\n\nx = new Int8Array( [0,1,2,3,4] );\n\nout = pdf( x, {\n\t'dtype': 'int32'\n});\n// returns Int32Array( [0,0,0,0,0] )\n\n// Works for plain arrays, as well...\nout = pdf( [0,0.5,1,1.5,2], {\n\t'dtype': 'uint8'\n});\n// returns Uint8Array( [0,0,0,0,0] )\n```\n\nBy default, the function returns a new data structure. To mutate the input data structure (e.g., when input values can be discarded or when optimizing memory usage), set the `copy` option to `false`.\n\n``` javascript\nvar bool,\n\tmat,\n\tout,\n\tx,\n\ti;\n\nx = [ 0, 0.5, 1, 1.5, 2 ];\n\nout = pdf( x, {\n\t'copy': false\n});\n// returns [ 0, ~0.441, ~0.607, ~0.487, ~0.271, ~0.11 ]\n\nbool = ( x === out );\n// returns true\n\nx = new Float32Array( 6 );\nfor ( i = 0; i < 6; i++ ) {\n\tx[ i ] = i * 0.5;\n}\nmat = matrix( x, [3,2], 'float32' );\n/*\n\t[ 0  0.5\n\t  1  1.5\n\t  2  2.5 ]\n*/\n\nout = pdf( mat, {\n\t'copy': false\n});\n/*\n\t[ 0     ~0.441\n\t ~0.607 ~0.487\n\t ~0.271 ~0.11 ]\n*/\n\nbool = ( mat === out );\n// returns true\n```\n\n\n## Notes\n\n*\tIf an element is __not__ a numeric value, the evaluated [PDF](https://en.wikipedia.org/wiki/Rayleigh_distribution) is `NaN`.\n\n\t``` javascript\n\tvar data, out;\n\n\tout = pdf( null );\n\t// returns NaN\n\n\tout = pdf( true );\n\t// returns NaN\n\n\tout = pdf( {'a':'b'} );\n\t// returns NaN\n\n\tout = pdf( [ true, null, [] ] );\n\t// returns [ NaN, NaN, NaN ]\n\n\tfunction getValue( d, i ) {\n\t\treturn d.x;\n\t}\n\tdata = [\n\t\t{'x':true},\n\t\t{'x':[]},\n\t\t{'x':{}},\n\t\t{'x':null}\n\t];\n\n\tout = pdf( data, {\n\t\t'accessor': getValue\n\t});\n\t// returns [ NaN, NaN, NaN, NaN ]\n\n\tout = pdf( data, {\n\t\t'path': 'x'\n\t});\n\t/*\n\t\t[\n\t\t\t{'x':NaN},\n\t\t\t{'x':NaN},\n\t\t\t{'x':NaN,\n\t\t\t{'x':NaN}\n\t\t]\n\t*/\n\t```\n\n*\tBe careful when providing a data structure which contains non-numeric elements and specifying an `integer` output data type, as `NaN` values are cast to `0`.\n\n\t``` javascript\n\tvar out = pdf( [ true, null, [] ], {\n\t\t'dtype': 'int8'\n\t});\n\t// returns Int8Array( [0,0,0] );\n\t```\n\n\n## Examples\n\n``` javascript\nvar pdf = require( 'distributions-rayleigh-pdf' ),\n\tmatrix = require( 'dstructs-matrix' );\n\nvar data,\n\tmat,\n\tout,\n\ttmp,\n\ti;\n\n// Plain arrays...\ndata = new Array( 10 );\nfor ( i = 0; i < data.length; i++ ) {\n\tdata[ i ] = i * 0.5;\n}\nout = pdf( data );\n\n// Object arrays (accessors)...\nfunction getValue( d ) {\n\treturn d.x;\n}\nfor ( i = 0; i < data.length; i++ ) {\n\tdata[ i ] = {\n\t\t'x': data[ i ]\n\t};\n}\nout = pdf( data, {\n\t'accessor': getValue\n});\n\n// Deep set arrays...\nfor ( i = 0; i < data.length; i++ ) {\n\tdata[ i ] = {\n\t\t'x': [ i, data[ i ].x ]\n\t};\n}\nout = pdf( data, {\n\t'path': 'x/1',\n\t'sep': '/'\n});\n\n// Typed arrays...\ndata = new Float32Array( 10 );\nfor ( i = 0; i < data.length; i++ ) {\n\tdata[ i ] = i * 0.5;\n}\nout = pdf( data );\n\n// Matrices...\nmat = matrix( data, [5,2], 'float32' );\nout = pdf( mat );\n\n// Matrices (custom output data type)...\nout = pdf( mat, {\n\t'dtype': 'uint8'\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. The [Compute.io](https://github.com/compute-io) Authors.\n\n\n[npm-image]: http://img.shields.io/npm/v/distributions-rayleigh-pdf.svg\n[npm-url]: https://npmjs.org/package/distributions-rayleigh-pdf\n\n[travis-image]: http://img.shields.io/travis/distributions-io/rayleigh-pdf/master.svg\n[travis-url]: https://travis-ci.org/distributions-io/rayleigh-pdf\n\n[codecov-image]: https://img.shields.io/codecov/c/github/distributions-io/rayleigh-pdf/master.svg\n[codecov-url]: https://codecov.io/github/distributions-io/rayleigh-pdf?branch=master\n\n[dependencies-image]: http://img.shields.io/david/distributions-io/rayleigh-pdf.svg\n[dependencies-url]: https://david-dm.org/distributions-io/rayleigh-pdf\n\n[dev-dependencies-image]: http://img.shields.io/david/dev/distributions-io/rayleigh-pdf.svg\n[dev-dependencies-url]: https://david-dm.org/dev/distributions-io/rayleigh-pdf\n\n[github-issues-image]: http://img.shields.io/github/issues/distributions-io/rayleigh-pdf.svg\n[github-issues-url]: https://github.com/distributions-io/rayleigh-pdf/issues\n","maintainers":[{"name":"kgryte","email":"kgryte@gmail.com"},{"name":"planeshifter","email":"pgb@andrew.cmu.edu"}],"time":{"modified":"2022-06-15T05:27:53.389Z","created":"2015-11-04T09:20:21.865Z","0.0.0":"2015-11-04T09:20:21.865Z","0.0.1":"2015-11-05T02:26:21.171Z"},"homepage":"https://github.com/distributions-io/rayleigh-pdf#readme","keywords":["distributions.io","distributions","probability","statistics","stats","pdf","exponential family","continuous distribution"],"repository":{"type":"git","url":"git://github.com/distributions-io/rayleigh-pdf.git"},"contributors":[{"name":"Philipp Burckhardt","email":"pburckhardt@outlook.com"}],"author":{"name":"Philipp Burckhardt","email":"pburckhardt@outlook.com"},"bugs":{"url":"https://github.com/distributions-io/rayleigh-pdf/issues"},"license":"MIT","readmeFilename":"README.md"}