Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/simple-statistics/stream-statistics
streaming statistical calculations for node
https://github.com/simple-statistics/stream-statistics
javascript statistics
Last synced: about 2 months ago
JSON representation
streaming statistical calculations for node
- Host: GitHub
- URL: https://github.com/simple-statistics/stream-statistics
- Owner: simple-statistics
- License: bsd-3-clause
- Archived: true
- Created: 2012-06-27T16:43:40.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2017-04-10T20:42:37.000Z (almost 8 years ago)
- Last Synced: 2024-10-03T00:24:18.295Z (3 months ago)
- Topics: javascript, statistics
- Language: JavaScript
- Homepage:
- Size: 171 KB
- Stars: 61
- Watchers: 6
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/tmcw/stream-statistics.svg?branch=v0.1.0)](https://travis-ci.org/tmcw/stream-statistics)
![](https://farm9.staticflickr.com/8282/7711892138_6a4c08cd71_b.jpg)
## stream-statistics
### Install
npm install stream-statistics
### API
This module exposes a single function that creates a stream. The stream
reads data, which it parses with `parseFloat()`, and computes statistics
on that data. When the input stream ends, `stream-statistics` emits the
`data` object.The statistics object has the following members:
* `min`
* `max`
* `sum`
* `mean`
* `mode`
* `variance`
* `standard_deviation`
* `geometric_mean`
* `harmonic_mean``mode` computation expects the stream to deliver numbers in sorted lowest-first
order, and will return `undefined` if that expectation is not met.### Use
```javascript
var streamStatistics = require('stream-statistics'),
assert = require('assert');function rangeStream(a, b) {
var rs = new Readable({ objectMode: true });
for (var i = 10; i < 1000; i++) { rs.push(i); }
rs.push(null);
return rs;
}rangeStream(10, 1000).pipe(streamStatistics())
.on('data', function(d) {
assert.equal(d.min, 10);
});
```## cli
This also provides a binary, `sstatistics`, that you can get if you
`npm install -g` the library. Pipe numbers into it and it'll return
a basic set of stats about its input.![](https://github.com/tmcw/stream-statistics/blob/master/screenshot.png?raw=true)
## [Documentation](https://github.com/tmcw/stream-statistics/wiki)
## See Also
* The sister project, [simple-statistics](https://github.com/tmcw/simple-statistics), that implements
many of the same measures in straightforward and literate fashion
* [streaming-k-means](https://github.com/piatra/streaming-k-means) implements k-means clustering in an online fashion