stats-collector
Description
Collect stats about numbers. This library provides a few different default collectors, but allows you to add your own "stat collectors" by exposing an API that lets you pass in reducer-like functions that act on numbers passed to it.
stats-collector
comes in 2 formats: a
node.js library
and a
command line tool.
For examples and api documentation, continue reading below.
Node.js Library
Getting Started
Install the module with: npm install stats-collector
Usage (Method 1)
;const stats = ;stats;console;
Usage (Method 2)
;const stats = ;stats;stats;stats;stats;console;
Usage (Different types of collectors)
;const c1 = ; // 0 default collectorsconst c2 = ; // 5 default collectorsconst c3 = ; // 8 default collectorsconst c4 = ; // 21 default collectorsconst collectors = libcollectors; // some collector functionsconst filters = libfilters; // some filter functionsconsole;
Example Output
The following table shows you the results of initializing a stats collector, then running the following statments:
stats;const results = stats;
Collector Type | Results |
---|---|
BaseStats | {} |
BasicNumberStats | { "count": 5, "max": 5, "mean": 3, "min": 1, "sum": 15 } |
NumberStats | { "count": 5, "max": 5, "mean": 3, "min": 1, "powerSumAvgRunning": 11, "product": 120, "standardDeviationRunning": 1.5811388300841898, "sum": 15, "varianceRunning": 2.5 } |
AdvancedNumberStats | { "amean": 3, "count": 5, "count_even": 2, "count_float": 0, "count_integer": 5, "count_negative": 0, "count_nonZero": 5, "count_odd": 3, "count_positive": 5, "count_prime": 3, "count_zero": 0, "gmean": 2.605171084697352, "hmean": 2.18978102189781, "max": 5, "mean": 3, "median": 3, "midRange": 3, "min": 1, "powerSumAvgRunning": 11, "product": 120, "range": 4, "standardDeviationRunning": 1.5811388300841898, "standardDeviationStable": 1.5811388300841898, "sum": 15, "sumOfRecipricals": 2.283333333333333, "sumOfSquaredDeviationsStable": 10, "varianceRunning": 2.5, "varianceStable": 2.5 } |
API Documentation
Read the API Docs by visiting the project site here:
Command Line Tool
Installation
The command line utility can be install via npm install -g stats-collector
.
After doing so, you will have access to stats-collector
from the command line.
$ stats-collector -h Usage: stats-collector [options] <values> Options: -h, --help output usage information -v, --version output the version number -c, --collectors [collectors] add collectors -f, --filters [filters] add filters -t, --type [type] type of stats [empty,basic,stats,advanced] -p, --pipe whether or not to accept piped data from stdin
Examples
Default behavior
Here is the default behavior when passing in 5 numbers.
$ stats-collector 1,2,3,4,5
Get "advanced" stats about 10 random numbers
The example uses the --pipe
functionality:
$ | stats-collector -t advanced --pipe
See Also
- covariance
- d3-array
- diversity
- ezstats
- fast-stats
- gauss
- math-statistics
- stats-analysis
- stats-incremental
- stats-lite
- stats-percentile
- statsjs
- stream-statistics
- summary
- summary-statistics
- very-simple-statistics
License
Copyright (c) 2015 skratchdot
Licensed under the MIT license.