{"id":17166706,"url":"https://github.com/willf/streaming-percentiles-js","last_synced_at":"2026-01-05T12:44:11.235Z","repository":{"id":66569848,"uuid":"318610580","full_name":"willf/streaming-percentiles-js","owner":"willf","description":"JavaScript library with implementations of multiple streaming percentile algorithms","archived":false,"fork":false,"pushed_at":"2018-03-08T21:26:10.000Z","size":140,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T12:52:25.997Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/willf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-04T19:01:16.000Z","updated_at":"2024-10-31T21:16:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"317c3786-460a-46b1-bee3-81ebdd205ace","html_url":"https://github.com/willf/streaming-percentiles-js","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willf%2Fstreaming-percentiles-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willf%2Fstreaming-percentiles-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willf%2Fstreaming-percentiles-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willf%2Fstreaming-percentiles-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/willf","download_url":"https://codeload.github.com/willf/streaming-percentiles-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245325221,"owners_count":20596818,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T23:06:27.335Z","updated_at":"2026-01-05T12:44:11.181Z","avatar_url":"https://github.com/willf.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Streaming Percentiles\n\nThis is a reusable JavaScript library with implementations of various\npercentile algorithms on streams of data.  These algorithms all\ncalculate only approximate percentiles, not exact percentiles.\n\nFor more on streaming percentiles, see [Calculating Percentiles on\nStreaming Data](https://stevenengelhardt.com/post-series/calculating-percentiles-on-streaming-data-2018/).\n\n## Installing\n\nIf you use NPM, `npm install streaming-percentiles`.  Otherwise,\ndownload the [latest release\nbinaries](https://sengelha.github.io/streaming-percentiles-js/streamingPercentiles.v1.zip)\nor the [latest release source\ncode](https://github.com/sengelha/streaming-percentiles-js/releases/latest).\nYou can also load directly from\n[unpkg.com](https://unpkg.com/streaming-percentiles/).\n\nFor convenience, you can also use the [latest release\nbinaries](https://sengelha.github.io/streaming-percentiles-js/streamingPercentiles.v1.zip)\ndirectly from a web browser:\n\n```html\n\u003cscript src=\"//sengelha.github.io/streaming-percentiles-js/streamingPercentiles.v1.min.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\nvar gk = new streamingPercentiles.GK(0.1);\n...\n\u003c/script\u003e\n```\n\n## Example\n\nHere's a simple example on how to use the Greenwald-Khanna streaming\npercentile algorithm:\n\n```javascript\nvar sp = require('streaming-percentiles');\n\n// epsilon is allowable error.  As epsilon becomes smaller, the\n// accuracy of the approximations improves, but the class consumes\n// more memory.\nvar epsilon = 0.1;\nvar gk = new sp.GK(epsilon);\nfor (var i = 0; i \u003c 1000; ++i)\n    gk.insert(Math.random());\nvar p50 = gk.quantile(0.5); // Approx. median\nvar p95 = gk.quantile(0.95); // Approx. 95th percentile\n```\n\n## API Reference\n\n### class GK(*epsilon*)\n\nConstruct an object which implements the Greenwald-Khanna streaming\npercentile algorithm with allowable error *epsilon*.\n\nExample:\n```javascript\nvar sp = require('streaming-percentiles');\nvar gk = new sp.GK(0.1);\n```\n\n### *gk*.insert(*value*)\n\nLogs the observation of a value.\n\nExample:\n```javascript\ngk.insert(Math.random());\n```\n\n### *gk*.quantile(*phi*)\n\nCompute the approximate quantile at *phi*.  For example, the 95th\npercentile corresponds to *phi* = 0.95.\n\nExample:\n```javascript\nvar p50 = gk.quantile(0.5);\n```\n\n## License\n\nThis project is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillf%2Fstreaming-percentiles-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwillf%2Fstreaming-percentiles-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillf%2Fstreaming-percentiles-js/lists"}