Socket
Socket
Sign inDemoInstall

streaming-percentiles

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    streaming-percentiles

Implementations of various streaming percentile algorithms


Version published
Weekly downloads
162
increased by95.18%
Maintainers
1
Install size
160 kB
Created
Weekly downloads
 

Changelog

Source

2.2.0 - 2018-04-20

  • Finish consolidation of streaming-percentiles-cpp and streaming-percentiles-js by adding support of publishing streaming-percentiles package to NPM

Readme

Source

streaming-percentiles

This is a library with implementations of various percentile algorithms on streams of data, with support for the following languages:

  • C++
  • JavaScript

For more on streaming percentiles, see Calculating Percentiles on Streaming Data.

Obtaining the Library

You can download pre-built versions of the library from the streaming-percentiles-cpp releases page. Otherwise see CONTRIBUTING.md for instructions on how to compile the library from source.

Usage Example

C++

Here's a simple example on how to use the Greenwald-Khanna streaming percentile algorithm from C++:

#include <stmpct/gk.hpp>

using namespace stmpct;

double epsilon = 0.1;
gk g(epsilon);
for (int i = 0; i < 1000; ++i)
    g.insert(rand());
double p50 = g.quantile(0.5); // Approx. median
double p95 = g.quantile(0.95); // Approx. 95th percentile

JavaScript

Node.JS

Here's how to use the library from Node.JS:

var sp = require('streaming-percentiles');

var epsilon = 0.1;
var g = new sp.GK(epsilon);
for (var i = 0; i < 1000; ++i)
    g.insert(Math.random());
var p50 = g.quantile(0.5); // Approx. median
var p95 = g.quantile(0.95); // Approx. 95th percentile
Browser

Here's how to use the library from a browser. Note that the default module name is streamingPercentiles:

<script src="streamingPercentiles.v1.min.js"></script>
<script>
var epsilon = 0.1;
var gk = new streamingPercentiles.GK(epsilon);
for (var i = 0; i < 1000; ++i)
    g.insert(Math.random());
var p50 = g.quantile(0.5);
</script>

API Reference

Coming soon!

Contributing

If you are interested in contributing to the library, please see CONTRIBUTING.md.

Keywords

FAQs

Last updated on 20 Apr 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc