{"id":16731406,"url":"https://github.com/skratchdot/stats-collector","last_synced_at":"2025-03-15T18:19:33.377Z","repository":{"id":57370235,"uuid":"46368528","full_name":"skratchdot/stats-collector","owner":"skratchdot","description":"Collect stats about numbers","archived":false,"fork":false,"pushed_at":"2016-10-06T16:00:19.000Z","size":563,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-23T00:19:29.363Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://projects.skratchdot.com/stats-collector/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/skratchdot.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-11-17T18:59:06.000Z","updated_at":"2018-11-30T13:22:10.000Z","dependencies_parsed_at":"2022-09-26T16:41:08.440Z","dependency_job_id":null,"html_url":"https://github.com/skratchdot/stats-collector","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skratchdot%2Fstats-collector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skratchdot%2Fstats-collector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skratchdot%2Fstats-collector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skratchdot%2Fstats-collector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skratchdot","download_url":"https://codeload.github.com/skratchdot/stats-collector/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243770283,"owners_count":20345276,"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-12T23:36:56.897Z","updated_at":"2025-03-15T18:19:33.358Z","avatar_url":"https://github.com/skratchdot.png","language":"JavaScript","funding_links":["https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=59LH5AHNQ8XZW"],"categories":[],"sub_categories":[],"readme":"# stats-collector\n\n[![NPM version](https://badge.fury.io/js/stats-collector.svg)](http://badge.fury.io/js/stats-collector)\n[![Build Status](https://travis-ci.org/skratchdot/stats-collector.png?branch=master)](https://travis-ci.org/skratchdot/stats-collector)\n[![Code Climate](https://codeclimate.com/github/skratchdot/stats-collector.png)](https://codeclimate.com/github/skratchdot/stats-collector)\n[![Coverage Status](https://coveralls.io/repos/skratchdot/stats-collector/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/skratchdot/stats-collector?branch=master)\n[![Dependency Status](https://david-dm.org/skratchdot/stats-collector.svg)](https://david-dm.org/skratchdot/stats-collector)\n[![devDependency Status](https://david-dm.org/skratchdot/stats-collector/dev-status.svg)](https://david-dm.org/skratchdot/stats-collector#info=devDependencies)\n\n[![NPM](https://nodei.co/npm/stats-collector.png)](https://npmjs.org/package/stats-collector)\n\n[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=59LH5AHNQ8XZW)\n\n\n## Description\n\nCollect stats about numbers.  This library provides a few different default\ncollectors, but allows you to add your own \"stat collectors\" by exposing an\nAPI that lets you pass in reducer-like functions that act on numbers passed\nto it.\n\n`stats-collector` comes in 2 formats: a\n[node.js library](#getting-started)\nand a\n[command line tool](#command-line-tool).\n\nFor examples and api documentation, continue reading below.\n\n\n## Node.js Library\n\n### Getting Started\n\nInstall the module with: `npm install stats-collector`\n\n[View Live Demo on Tonic](https://tonicdev.com/npm/stats-collector)\n\n#### Usage (Method 1)\n\n```javascript\nimport * as lib from 'stats-collector';\nconst stats = new lib.NumberStats();\nstats.processAll([1,2,3,4,5]);\nconsole.log(stats.get());\n```\n\n#### Usage (Method 2)\n\n```javascript\nimport NumberStats from 'stats-collector/lib/NumberStats';\nconst stats = new StatsCollector();\nstats.process(1);\nstats.process(2);\nstats.process(3);\nstats.processAll([4, 5]);\nconsole.log(stats.get());\n```\n\n#### Usage (Different types of collectors)\n\n```javascript\nimport * as lib from 'stats-collector';\nconst c1 = new lib.BaseStats();            // 0 default collectors\nconst c2 = new lib.BasicNumberStats();     // 5 default collectors\nconst c3 = new lib.NumberStats();          // 8 default collectors\nconst c4 = new lib.AdvancedNumberStats();  // 21 default collectors\nconst collectors = lib.collectors; // some collector functions\nconst filters = lib.filters; // some filter functions\nconsole.log(c1.get(), c2.get(), c3.get(), c4.get(), collectors, filters);\n```\n\n### Example Output\n\nThe following table shows you the results of initializing a\nstats collector, then running the following statments:\n\n```javascript\nstats.processAll([1, 2, 3, 4, 5]);\nconst results = stats.get();\n```\n\n|Collector Type|Results|\n|--------------|-------|\n|BaseStats|{}|\n|BasicNumberStats|{\u003cbr /\u003e\u0026nbsp;\"count\": 5,\u003cbr /\u003e\u0026nbsp;\"max\": 5,\u003cbr /\u003e\u0026nbsp;\"mean\": 3,\u003cbr /\u003e\u0026nbsp;\"min\": 1,\u003cbr /\u003e\u0026nbsp;\"sum\": 15\u003cbr /\u003e}|\n|NumberStats|{\u003cbr /\u003e\u0026nbsp;\"count\": 5,\u003cbr /\u003e\u0026nbsp;\"max\": 5,\u003cbr /\u003e\u0026nbsp;\"mean\": 3,\u003cbr /\u003e\u0026nbsp;\"min\": 1,\u003cbr /\u003e\u0026nbsp;\"powerSumAvgRunning\": 11,\u003cbr /\u003e\u0026nbsp;\"product\": 120,\u003cbr /\u003e\u0026nbsp;\"standardDeviationRunning\": 1.5811388300841898,\u003cbr /\u003e\u0026nbsp;\"sum\": 15,\u003cbr /\u003e\u0026nbsp;\"varianceRunning\": 2.5\u003cbr /\u003e}|\n|AdvancedNumberStats|{\u003cbr /\u003e\u0026nbsp;\"amean\": 3,\u003cbr /\u003e\u0026nbsp;\"count\": 5,\u003cbr /\u003e\u0026nbsp;\"count_even\": 2,\u003cbr /\u003e\u0026nbsp;\"count_float\": 0,\u003cbr /\u003e\u0026nbsp;\"count_integer\": 5,\u003cbr /\u003e\u0026nbsp;\"count_negative\": 0,\u003cbr /\u003e\u0026nbsp;\"count_nonZero\": 5,\u003cbr /\u003e\u0026nbsp;\"count_odd\": 3,\u003cbr /\u003e\u0026nbsp;\"count_positive\": 5,\u003cbr /\u003e\u0026nbsp;\"count_prime\": 3,\u003cbr /\u003e\u0026nbsp;\"count_zero\": 0,\u003cbr /\u003e\u0026nbsp;\"gmean\": 2.605171084697352,\u003cbr /\u003e\u0026nbsp;\"hmean\": 2.18978102189781,\u003cbr /\u003e\u0026nbsp;\"max\": 5,\u003cbr /\u003e\u0026nbsp;\"mean\": 3,\u003cbr /\u003e\u0026nbsp;\"median\": 3,\u003cbr /\u003e\u0026nbsp;\"midRange\": 3,\u003cbr /\u003e\u0026nbsp;\"min\": 1,\u003cbr /\u003e\u0026nbsp;\"powerSumAvgRunning\": 11,\u003cbr /\u003e\u0026nbsp;\"product\": 120,\u003cbr /\u003e\u0026nbsp;\"range\": 4,\u003cbr /\u003e\u0026nbsp;\"standardDeviationRunning\": 1.5811388300841898,\u003cbr /\u003e\u0026nbsp;\"standardDeviationStable\": 1.5811388300841898,\u003cbr /\u003e\u0026nbsp;\"sum\": 15,\u003cbr /\u003e\u0026nbsp;\"sumOfRecipricals\": 2.283333333333333,\u003cbr /\u003e\u0026nbsp;\"sumOfSquaredDeviationsStable\": 10,\u003cbr /\u003e\u0026nbsp;\"varianceRunning\": 2.5,\u003cbr /\u003e\u0026nbsp;\"varianceStable\": 2.5\u003cbr /\u003e}|\n\n\n### API Documentation\n\nRead the [API Docs](http://projects.skratchdot.com/stats-collector/)\nby visiting the project site here:\n\n- [http://projects.skratchdot.com/stats-collector/](http://projects.skratchdot.com/stats-collector/)\n\n\n## Command Line Tool\n\n### Installation\n\nThe command line utility can be install via `npm install -g stats-collector`.\n\nAfter doing so, you will have access to `stats-collector` from the command line.\n\n```bash\n$ stats-collector -h\n\n  Usage: stats-collector [options] \u003cvalues\u003e\n\n  Options:\n\n    -h, --help                     output usage information\n    -v, --version                  output the version number\n    -c, --collectors [collectors]  add collectors\n    -f, --filters [filters]        add filters\n    -t, --type [type]              type of stats [empty,basic,stats,advanced]\n    -p, --pipe                     whether or not to accept piped data from stdin\n```\n\n### Examples\n\n#### Default behavior\n\nHere is the default behavior when passing in 5 numbers.\n\n```bash\n$ stats-collector 1,2,3,4,5\n{\n  \"count\": 5,\n  \"max\": 5,\n  \"mean\": 3,\n  \"min\": 1,\n  \"powerSumAvgRunning\": 11,\n  \"product\": 120,\n  \"standardDeviationRunning\": 1.5811388300841898,\n  \"sum\": 15,\n  \"varianceRunning\": 2.5\n}\n```\n\n#### Get \"advanced\" stats about 10 random numbers\n\nThe example uses the `--pipe` functionality:\n\n```bash\n$ for i in {1..10}; do echo $RANDOM; done | stats-collector -t advanced --pipe\n{\n  \"amean\": 15239.3,\n  \"count\": 10,\n  \"count_even\": 7,\n  \"count_float\": 0,\n  \"count_integer\": 10,\n  \"count_negative\": 0,\n  \"count_nonZero\": 10,\n  \"count_odd\": 3,\n  \"count_positive\": 10,\n  \"count_prime\": 1,\n  \"count_zero\": 0,\n  \"gmean\": 9896.019927976335,\n  \"hmean\": 5947.676087129243,\n  \"max\": 30937,\n  \"mean\": 15239.3,\n  \"median\": 26478,\n  \"midRange\": 16430.5,\n  \"min\": 1924,\n  \"powerSumAvgRunning\": 360452286.7,\n  \"product\": 9.007527812504433e+39,\n  \"range\": 29013,\n  \"standardDeviationRunning\": 11935.754978215662,\n  \"standardDeviationStable\": 11935.754978215662,\n  \"sum\": 152393,\n  \"sumOfRecipricals\": 0.0016813289515950568,\n  \"sumOfSquaredDeviationsStable\": 1282160222.1,\n  \"varianceRunning\": 142462246.89999998,\n  \"varianceStable\": 142462246.89999998\n}\n```\n\n\n## Links\n\n- [Source Code](https://github.com/skratchdot/stats-collector)\n- [API Docs](http://projects.skratchdot.com/stats-collector/)\n- [Project Page](http://projects.skratchdot.com/stats-collector/)\n- [Changelog](https://github.com/skratchdot/stats-collector/blob/master/CHANGELOG.md)\n- [Live example on Tonic](https://tonicdev.com/npm/stats-collector)\n\n\n## See Also\n\n- [covariance](https://www.npmjs.com/package/covariance)\n- [d3-array](https://www.npmjs.com/package/d3-array)\n- [diversity](https://www.npmjs.com/package/diversity)\n- [ezstats](https://www.npmjs.com/package/ezstats)\n- [fast-stats](https://www.npmjs.com/package/fast-stats)\n- [gauss](https://www.npmjs.com/package/gauss)\n- [math-statistics](https://www.npmjs.com/package/math-statistics)\n- [stats-analysis](https://www.npmjs.com/package/stats-analysis)\n- [stats-incremental](https://www.npmjs.com/package/stats-incremental)\n- [stats-lite](https://www.npmjs.com/package/stats-lite)\n- [stats-percentile](https://www.npmjs.com/package/stats-percentile)\n- [statsjs](https://www.npmjs.com/package/statsjs)\n- [stream-statistics](https://www.npmjs.com/package/stream-statistics)\n- [summary](https://www.npmjs.com/package/summary)\n- [summary-statistics](https://www.npmjs.com/package/summary-statistics)\n- [very-simple-statistics](https://www.npmjs.com/package/very-simple-statistics)\n\n\n## License\n\nCopyright (c) 2015 [skratchdot](http://skratchdot.com/)  \nLicensed under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskratchdot%2Fstats-collector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskratchdot%2Fstats-collector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskratchdot%2Fstats-collector/lists"}