{"_id":"distributions-normal-pdf","_rev":"6-4c91776dc48681959a7a92e6647e0926","name":"distributions-normal-pdf","description":"Normal distribution probability density function (PDF)","dist-tags":{"latest":"0.0.2"},"versions":{"0.0.0":{"name":"distributions-normal-pdf","version":"0.0.0","description":"Normal 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","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-pdf.git"},"keywords":["distributions.io","distributions","probability","statistics","stats","pdf","gaussian","normal","bell-shape"],"bugs":{"url":"https://github.com/distributions-io/normal-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":"^1.0.0","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"},"license":"MIT","gitHead":"ad529da7d017879ce072f81c7bf229ab9e78be40","homepage":"https://github.com/distributions-io/normal-pdf#readme","_id":"distributions-normal-pdf@0.0.0","_shasum":"dff4280595f630fa9c59c340533940086dd548b7","_from":".","_npmVersion":"2.8.4","_nodeVersion":"4.0.0","_npmUser":{"name":"planeshifter","email":"pgb@andrew.cmu.edu"},"dist":{"shasum":"dff4280595f630fa9c59c340533940086dd548b7","tarball":"https://registry.npmjs.org/distributions-normal-pdf/-/distributions-normal-pdf-0.0.0.tgz","integrity":"sha512-1ycIDNgfyJm7zv2567vMZmQti+OV2L6gkQ6QyisnHt4Rg3SHxZ6RawVQ1xvmEgefnX9X3hctYY0dtWgiySNaKw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDIMplW8CY7vkDIsGmPF/broqHsGGz8GrDYRE6LtFyLbAIgesnimE3ZY5maZ9yI0rtf8yVAvCdARCbbPQzTI4m0zPw="}]},"maintainers":[{"name":"planeshifter","email":"pgb@andrew.cmu.edu"}]},"0.0.1":{"name":"distributions-normal-pdf","version":"0.0.1","description":"Normal 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","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-pdf.git"},"keywords":["distributions.io","distributions","probability","statistics","stats","pdf","gaussian","normal","bell-shape"],"bugs":{"url":"https://github.com/distributions-io/normal-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":"^1.0.0","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"},"license":"MIT","gitHead":"3acb413cb69627e268abf4ac4f119c469b8b0614","homepage":"https://github.com/distributions-io/normal-pdf#readme","_id":"distributions-normal-pdf@0.0.1","_shasum":"0c0a65f40eb5c5ad1dab77076df55599c3783f88","_from":".","_npmVersion":"2.8.4","_nodeVersion":"4.0.0","_npmUser":{"name":"planeshifter","email":"pgb@andrew.cmu.edu"},"dist":{"shasum":"0c0a65f40eb5c5ad1dab77076df55599c3783f88","tarball":"https://registry.npmjs.org/distributions-normal-pdf/-/distributions-normal-pdf-0.0.1.tgz","integrity":"sha512-39VgNE4olxa9sjhTx0z9sVhGxaVI7IFxK0tT69TQFx69N4zhFjsHy5FH0TSha24wNXZdmqN9CP15kh0zEDtxtw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBt4rlfMnCq45V+PKjS7XKd4FqQIr45brrxexvRXOah2AiEAv1XJuCvb8UWjfMURy1W/Nzf/mm+S/vZRhTk9aP8g2XQ="}]},"maintainers":[{"name":"kgryte","email":"kgryte@gmail.com"},{"name":"planeshifter","email":"pgb@andrew.cmu.edu"}]},"0.0.2":{"name":"distributions-normal-pdf","version":"0.0.2","description":"Normal 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","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-pdf.git"},"keywords":["distributions.io","distributions","probability","statistics","stats","pdf","gaussian","normal","bell-shape"],"bugs":{"url":"https://github.com/distributions-io/normal-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":"^1.0.0","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"},"license":"MIT","gitHead":"6c883c1d5b0596bd6298a419b876e5732c25e35d","homepage":"https://github.com/distributions-io/normal-pdf#readme","_id":"distributions-normal-pdf@0.0.2","_shasum":"03ae576fc78deb9f0d167531b4bef5c1efc2ac5b","_from":".","_npmVersion":"2.8.4","_nodeVersion":"4.0.0","_npmUser":{"name":"planeshifter","email":"pgb@andrew.cmu.edu"},"dist":{"shasum":"03ae576fc78deb9f0d167531b4bef5c1efc2ac5b","tarball":"https://registry.npmjs.org/distributions-normal-pdf/-/distributions-normal-pdf-0.0.2.tgz","integrity":"sha512-fOdYkun+Lx+eBP87E0dmPUnQ+wAuIE5prMGjjADONfxevSAHx1IZ4mmc8pgfzQTvND79N3kWVvwayS2A3ZkAMQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCBJOLV++vs2JfAyrAb8lWBw1lpy2d5xkBmwaUjranKxwIhAK1o1xgIVaKb+BjeZK6ZuCpKmwXXo+dedwhRf/P0eMGy"}]},"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> [Normal](https://en.wikipedia.org/wiki/Normal_distribution) distribution probability density function (PDF).\n\nThe [probability density function](https://en.wikipedia.org/wiki/Probability_density_function) (PDF) for a [normal](https://en.wikipedia.org/wiki/Normal_distribution) random variable is\n\n<div class=\"equation\" align=\"center\" data-raw-text=\" \tf(x;\\mu,\\sigma)=\\frac{1}{\\sigma\\sqrt{2\\pi}}\\, e^{-\\frac{(x - \\mu)^2}{2 \\sigma^2}}\" data-equation=\"eq:pdf_function\">\n\t<img src=\"https://cdn.rawgit.com/distributions-io/normal-pdf/041aba5f623f0203e608bb41ba2c4d0227665429/docs/img/eqn.svg\" alt=\"Probability density function (PDF) for a Normal distribution.\">\n\t<br>\n</div>\n\nwhere `mu` is the mean  and `sigma > 0` is the standard deviation.\n\n## Installation\n\n``` bash\n$ npm install distributions-normal-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-normal-pdf' );\n```\n\n#### pdf( x[, options] )\n\nEvaluates the [probability density function](https://en.wikipedia.org/wiki/Probability_density_function) (PDF) for the [normal](https://en.wikipedia.org/wiki/Normal_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\n// Standard Normal Distribution (mu=1, sigma=1):\n\nout = pdf( 1 );\n// returns 0.2419707\n\nout = pdf( -1 );\n// returns 0.2419707\n\nx = [ 0, 0.5, 1, 1.5, 2, 2.5 ];\nout = pdf( x );\n// returns [ ~0.399, ~0.352, ~0.242, ~0.13, ~0.054, ~0.0175 ]\n\nx = new Float32Array( x );\nout = pdf( x );\n// returns Float64Array( [~0.399,~0.352,~0.242,~0.13,~0.054,~0.0175] )\n\nx = new Float64Array( 6 );\nfor ( i = 0; i < 6; i++ ) {\n\tx[ i ] = i*0.5;\n}\nmat = matrix( x, [3,2], 'float64' );\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.399 ~0.352\n\t  ~0.242 ~0.13\n\t  ~0.054 ~0.0175 ]\n*/\n```\n\nThe function accepts the following `options`:\n\n*\t__mu__: mean . Default: `0`.\n*\t__sigma__: standard deviation. 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 [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 x = [ 0, 0.5, 1, 1.5, 2, 2.5 ];\n\nvar out = pdf( x, {\n\t'mu': 2,\n\t'sigma': 2,\n});\n// returns [ ~0.121, ~0.151, ~0.176, ~0.193, ~0.199, ~0.193 ]\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.399, ~0.352, ~0.242, ~0.13, ~0.054, ~0.0175 ]\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.399]},\n\t\t{'x':[1,~0.352]},\n\t\t{'x':[2,~0.242]},\n\t\t{'x':[3,~0.13]},\n\t\t{'x':[4,~0.054]},\n\t\t{'x':[5,~0.0175]}\n\t]\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'mu': 2,\n\t'sigma': 2,\n\t'dtype': 'int32'\n});\n// returns Int32Array( [0,0,1,0,0] )\n\n// Works for plain arrays, as well...\nout = pdf( [0,0.5,1,1.5,2], {\n\t'mu': 2,\n\t'sigma': 2,\n\t'dtype': 'uint8'\n});\n// returns Uint8Array( [0,0,1,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.399, ~0.352, ~0.242, ~0.13, ~0.054, ~0.0175 ]\n\nbool = ( x === out );\n// returns true\n\nx = new Int16Array( 6 );\nfor ( i = 0; i < 6; i++ ) {\n\tx[ i ] = i*0.5;\n}\nmat = matrix( x, [3,2], 'int16' );\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.399 ~0.352\n\t  ~0.242 ~0.13\n\t  ~0.054 ~0.0175 ]\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/Normal_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-normal-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 ] = -2.5 + 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 ] = -2.5 + 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-normal-pdf.svg\n[npm-url]: https://npmjs.org/package/distributions-normal-pdf\n\n[travis-image]: http://img.shields.io/travis/distributions-io/normal-pdf/master.svg\n[travis-url]: https://travis-ci.org/distributions-io/normal-pdf\n\n[codecov-image]: https://img.shields.io/codecov/c/github/distributions-io/normal-pdf/master.svg\n[codecov-url]: https://codecov.io/github/distributions-io/normal-pdf?branch=master\n\n[dependencies-image]: http://img.shields.io/david/distributions-io/normal-pdf.svg\n[dependencies-url]: https://david-dm.org/distributions-io/normal-pdf\n\n[dev-dependencies-image]: http://img.shields.io/david/dev/distributions-io/normal-pdf.svg\n[dev-dependencies-url]: https://david-dm.org/dev/distributions-io/normal-pdf\n\n[github-issues-image]: http://img.shields.io/github/issues/distributions-io/normal-pdf.svg\n[github-issues-url]: https://github.com/distributions-io/normal-pdf/issues\n","maintainers":[{"name":"kgryte","email":"kgryte@gmail.com"},{"name":"planeshifter","email":"pgb@andrew.cmu.edu"}],"time":{"modified":"2022-06-15T05:26:41.354Z","created":"2015-11-05T04:00:39.997Z","0.0.0":"2015-11-05T04:00:39.997Z","0.0.1":"2015-11-05T04:02:42.987Z","0.0.2":"2015-11-05T04:09:58.040Z"},"homepage":"https://github.com/distributions-io/normal-pdf#readme","keywords":["distributions.io","distributions","probability","statistics","stats","pdf","gaussian","normal","bell-shape"],"repository":{"type":"git","url":"git://github.com/distributions-io/normal-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/normal-pdf/issues"},"license":"MIT","readmeFilename":"README.md"}