Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

streaming-percentiles

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

streaming-percentiles

Implementations of various streaming percentile algorithms

  • 2.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
132
increased by153.85%
Maintainers
1
Weekly downloads
 
Created
Source

streaming-percentiles-cpp

This is a C++ library with implementations of various percentile algorithms on streams of data. Using the magic of emscripten, this package also cross-compiles a JavaScript version of the streaming percentiles library as well.

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('./streamingPercentiles.v1.min.js');

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

Package last updated on 20 Apr 2018

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc