{"name":"pdfast","version":"0.2.0","description":"Fast kernel density estimation library","main":"src/index.js","keywords":["pdf","kde","probabilty","density","function","estimation","kernel","estimator"],"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":"6b0d5c2830b8e00fd11e2561aeb267df5166ded0","_id":"pdfast@0.2.0","_shasum":"8cbc556e1bf2522177787c0de2e0d4373ba885c9","_from":".","_npmVersion":"3.7.1","_nodeVersion":"4.2.2","_npmUser":{"name":"gyosh","email":"will.gozali@gmail.com"},"dist":{"shasum":"8cbc556e1bf2522177787c0de2e0d4373ba885c9","tarball":"http://registry-npm.ywwl.com/pdfast/download/pdfast-0.2.0.tgz","integrity":"sha512-cq6TTu6qKSFUHwEahi68k/kqN2mfepjkGrG9Un70cgdRRKLKY6Rf8P8uvP2NvZktaQZNF3YE7agEkLj0vGK9bA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC+F9nBadOPMP6MjXIehzEenPQ6ppNj07nSdN+kPAAsVAIgfaml1vAfU9UdiJ7DmN6xzPzN/Yw4qMU/IdEahU/doMw="}],"size":5788,"noattachment":false,"key":"/pdfast/-/pdfast-0.2.0.tgz"},"maintainers":[{"name":"gyosh","email":"will.gozali@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/pdfast-0.2.0.tgz_1472749598248_0.8701685892883688"},"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":1472749598477,"_cnpm_publish_time":1472749598477,"dist-tags":{"latest":"0.2.0"}}