Skip to content
streaming statistical calculations for node
Find file
Latest commit eb4810e Apr 6, 2014 @tmcw 0.4.0
Failed to load latest commit information.
bin Add binary Jul 7, 2012
test Document mode Apr 6, 2014
.travis.yml Modernize Apr 3, 2014 Add screenshot and prep for 0.0.1 Jul 7, 2012
LICENSE Push license and readme updates Jun 27, 2012 Document mode Apr 6, 2014
index.js Document mode Apr 6, 2014
package.json 0.4.0 Apr 6, 2014
screenshot.png Add screenshot and prep for 0.0.1 Jul 7, 2012

Build Status



npm install stream-statistics


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.


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); }
    return rs;

rangeStream(10, 1000).pipe(streamStatistics())
    .on('data', function(d) {
        assert.equal(d.min, 10);


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.


See Also

  • The sister project, simple-statistics, that implements many of the same measures in straightforward and literate fashion
Something went wrong with that request. Please try again.