flow-quantiles

0.0.5 • Public • Published

flow-quantiles

Reduce transform stream which computes the quantiles over a stream of numeric data.

Note: in order to calculate the quantiles exactly, all data must be buffered into memory. As a result, this stream acts as a sink. Use caution when applying the transform to large datasets.

Installation

$ npm install flow-quantiles

Examples

var eventStream = require( 'event-stream' ),
    qStream = require( 'flow-quantiles' );
 
// Create some data...
var data = new Array( 1000 );
for ( var i = 0; i < data.length; i++ ) {
    data[ i ] = Math.round( Math.random() * 100 );
}
 
// Create a readable stream:
var readStream = eventStream.readArray( data );
 
// Create a new quantiles stream:
var stream = qStream()
    .quantiles( 10 )
    .stream();
 
// Pipe the data:
readStream.pipe( stream )
    .pipe( eventStream.stringify() )
    .pipe( process.stdout );

Tests

Unit tests use the Mocha test framework with Chai assertions.

Assuming you have installed Mocha, execute the following command in the top-level application directory to run the tests:

$ mocha

All new feature development should have corresponding unit tests to validate correct functionality.

License

MIT license.


Copyright

Copyright © 2014. Athan Reines.

Dependents (1)

Package Sidebar

Install

npm i flow-quantiles

Weekly Downloads

0

Version

0.0.5

License

none

Last publish

Collaborators

  • kgryte