{"name":"pdfast","version":"0.0.2","description":"Fast kernel density estimation library","main":"src/index.js","keywords":["pdf","probabilty","density","function","estimation","kernel"],"repository":{"type":"git","url":"git+https://github.com/gyosh/pdfast.git"},"bugs":{"url":"https://github.com/gyosh/pdfast"},"homepage":"https://github.com/gyosh/pdfast","scripts":{"test":"mocha --timeout 10000 $(find tests -name *.spec.js)"},"author":{"name":"William Gozali","email":"will.gozali@gmail.com"},"license":"MIT","devDependencies":{"chai":"^3.5.0","lodash":"^4.14.2","mocha":"^3.0.2","rewire":"^2.5.2"},"gitHead":"9627dad89d61cb868ee67fbee901232e683b7b57","_id":"pdfast@0.0.2","_shasum":"f5428e767c4108c2b11da15e5864e6c6cd383318","_from":".","_npmVersion":"3.7.1","_nodeVersion":"4.2.2","_npmUser":{"name":"gyosh","email":"will.gozali@gmail.com"},"dist":{"shasum":"f5428e767c4108c2b11da15e5864e6c6cd383318","tarball":"http://registry-npm.ywwl.com/pdfast/download/pdfast-0.0.2.tgz","integrity":"sha512-jItphozebnUih8yvL1N5NcpN/F5if5KQujR5vkI5g1e9cMpuA1j13jVUPceBa1H0aksQ62k7TW826merDSp9FQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCp0BSUjcXTvCp/LQXrlwo6NzdmXjn18M0GiWniHJXQtwIhALk5rU919MHIM5y03/zJ+EdBexgYvzH2KwaNUnDdr56w"}],"size":13204,"noattachment":false,"key":"/pdfast/-/pdfast-0.0.2.tgz"},"maintainers":[{"name":"gyosh","email":"will.gozali@gmail.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/pdfast-0.0.2.tgz_1470938211558_0.8392631823662668"},"directories":{},"readme":"[![Build Status](https://travis-ci.org/gyosh/pdfast.svg)](https://travis-ci.org/gyosh/pdfast)\n[![npm version](https://badge.fury.io/js/pdfast.svg)](https://badge.fury.io/js/pdfast)\n\n# About\n\nKernel Density Estimation, generating probability density function (pdf) using triangular kernel, optimized to run in O(N + K).\n\nWhere:\n\n  * N: number of elements in the sample.\n  * K: number of points to represent the pdf.\n\n# API\n\n## create(arr, options)\n\nCreate pdf with given array and options.\n\nOptions:\n\n  * `min`: min value for the pdf's x range. If resulting pdf won't fit, the pdf's left part will be squeezed, as [described here](http://stats.stackexchange.com/questions/65866/good-methods-for-density-plots-of-non-negative-variables-in-r). Defaults to smallest value in the array minus some threshold.\n  * `max`: max value for the pdf's x range. If resulting pdf won't fit, the pdf's right will be squeezed. Defaults to largest value in the array plus some threshold.\n  * `size`: number of points to represent the pdf. Defaults to 50.\n  * `width`: determine how many points to the left and right does an element affect, similar to *bandwidth* in kernel density estimation. Defaults to 2.\n\n```js\nvar arr = [1, 2, 3, 3, 4, 5, 5, 5, 6, 8, 9, 9];\nvar options = {\n  min: 0,\n  max: 10,\n  size: 12,\n  width: 2\n};\n\nvar pdf = pdfast.create(arr, options);\n```\n\n`pdf`'s value:\n```\n[ { x: 0, y: 0.020833333333333332 },\n  { x: 0.9090909090909091, y: 0.0625 },\n  { x: 1.8181818181818181, y: 0.10416666666666667 },\n  { x: 2.727272727272727, y: 0.125 },\n  { x: 3.6363636363636362, y: 0.14583333333333334 },\n  { x: 4.545454545454545, y: 0.16666666666666666 },\n  { x: 5.454545454545454, y: 0.10416666666666667 },\n  { x: 6.363636363636363, y: 0.041666666666666664 },\n  { x: 7.2727272727272725, y: 0.08333333333333333 },\n  { x: 8.181818181818182, y: 0.10416666666666667 },\n  { x: 9.09090909090909, y: 0.041666666666666664 },\n  { x: 10, y: 0 } ]\n```\n\n## getExpectedValueFromPdf(pdf)\n\n```js\nexpect(\n  pdfast.getExpectedValueFromPdf([\n    {x: 1, y: 0.2},\n    {x: 2, y: 0.3},\n    {x: 3, y: 0.3},\n    {x: 4, y: 0.2},\n    {x: 5, y: 0.0}\n  ])\n).closeTo(2.5, 1e-8);\n```\n\n## getXWithLeftTailArea(pdf, area)\n\n```js\nvar pdf = [\n  {x: 1, y: 0.2},\n  {x: 2, y: 0.4},\n  {x: 3, y: 0.3},\n  {x: 4, y: 0.075},\n  {x: 5, y: 0.025}\n];\n\nexpect(pdfast.getXWithLeftTailArea(pdf, 0)).equal(1);\nexpect(pdfast.getXWithLeftTailArea(pdf, 0.12)).equal(1);\nexpect(pdfast.getXWithLeftTailArea(pdf, 0.19)).equal(1);\nexpect(pdfast.getXWithLeftTailArea(pdf, 0.21)).equal(2);\nexpect(pdfast.getXWithLeftTailArea(pdf, 0.95)).equal(4);\nexpect(pdfast.getXWithLeftTailArea(pdf, 1)).equal(5);\n```\n\n## getPerplexity(pdf)\n\n```js\nexpect(\n  pdfast.getPerplexity([\n    {x: 1, y: 0.2},\n    {x: 2, y: 0.4},\n    {x: 3, y: 0.3},\n    {x: 4, y: 0.075},\n    {x: 5, y: 0.025}\n  ])\n).closeTo(3.8041316039860336, EPS);\n```\n\n## getUnifiedMinMax(arr, options)\n\nTakes the same options as `create`. Returns an object with key `min` and `max`.\n\nIf you left `min` or `max` or both to be non number, it will be filled with number which will fit the data distribution.\n\n## getUnifiedMinMaxMulti([arr1, arr2, ...], options)\n\nSimilar with `getUnifiedMinMax`, but takes list of arrays. The generated `min` and/or `max` will fit all the arrays' distribution.\n\nUseful when trying to generate pdf for multiple labelled data and want to display them in the same chart. With same `min` and `max`, one can combine the pdf correctly.\n\n# License\nMIT\n","publish_time":1470938213796,"_cnpm_publish_time":1470938213796,"dist-tags":{"latest":"0.2.0"}}