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 - npm Package Compare versions

Comparing version 2.3.0 to 3.0.0

6

package.json
{
"name": "streaming-percentiles",
"version": "2.3.0",
"version": "3.0.0",
"description": "Implementations of various streaming percentile algorithms",

@@ -19,6 +19,6 @@ "keywords": [

"type": "git",
"url": "git+https://github.com/sengelha/streaming-percentiles-cpp.git"
"url": "git+https://github.com/sengelha/streaming-percentiles.git"
},
"bugs": {
"url": "https://github.com/sengelha/streaming-percentiles-cpp/issues"
"url": "https://github.com/sengelha/streaming-percentiles/issues"
},

@@ -25,0 +25,0 @@ "scripts": {

# streaming-percentiles
## Build Status:
Develop branch: [![Build Status](https://travis-ci.org/sengelha/streaming-percentiles-cpp.svg?branch=develop)](https://travis-ci.org/sengelha/streaming-percentiles-cpp)
Master branch: [![Build Status](https://travis-ci.org/sengelha/streaming-percentiles-cpp.svg?branch=master)](https://travis-ci.org/sengelha/streaming-percentiles-cpp)
## Build Status
| Develop Branch | Master Branch |
| -------------- | ------------- |
| [![Build Status](https://travis-ci.org/sengelha/streaming-percentiles-cpp.svg?branch=develop)](https://travis-ci.org/sengelha/streaming-percentiles-cpp) | [![Build Status](https://travis-ci.org/sengelha/streaming-percentiles-cpp.svg?branch=master)](https://travis-ci.org/sengelha/streaming-percentiles-cpp) |
## About the Library
This is a cross-pltaform library with implementations of various
percentile algorithms on streams of data. For more on streaming
percentiles, see [Calculating Percentiles on Streaming
Data](//stevenengelhardt.com/post-series/calculating-percentiles-on-streaming-data-2018/).
percentile algorithms on streams of data. These algorithms allow
you to calculate approximate percentiles (e.g. 50th percentile,
95th percentile) in a single pass over a data set.
They are particularly useful for calculating percentiles for
immense data sets, for extremely high-throughput systems, or
for near-real time use cases.
The library supports the following languages:
- C++
- JavaScript
The library implements the following streaming percentile algorithms:
- [Greenwald-Khanna](doc/methodology/GK01.pdf)
- [Cormode-Korn-Muthukrishnan-Srivastava](doc/methodology/CKMS05.pdf) for high-biased, low-biased, uniform, and targeted quantiles
For more background on streaming
percentiles, see [Calculating Percentiles on Streaming
Data](//www.stevenengelhardt.com/postseries/calculating-percentiles-on-streaming-data/).
## Obtaining the Library

@@ -20,3 +37,3 @@

You can download pre-built binaries of the library from the
You can download the latest release of the library from the
[streaming-percentiles latest release

@@ -28,3 +45,3 @@ page](//github.com/sengelha/streaming-percentiles-cpp/releases/latest).

If you use NPM, `npm install streaming-percentiles`. Otherwise, download
pre-built binaries of the library from the [streaming-percentiles latest
the latest release of the library from the [streaming-percentiles latest
release

@@ -46,6 +63,6 @@ page](//github.com/sengelha/streaming-percentiles-cpp/releases/latest)

See `CONTRIBUTING.md` for instructions on how to build the release from
See [CONTRIBUTING.md](CONTRIBUTING.md) for instructions on how to build the release from
source.
## Usage Example
## Using the Library

@@ -60,6 +77,4 @@ ### C++

using namespace stmpct;
double epsilon = 0.1;
gk g(epsilon);
stmpct::gk<double> g(epsilon);
for (int i = 0; i < 1000; ++i)

@@ -75,3 +90,3 @@ g.insert(rand());

Here's how to use the library from Node.JS:
Here's an example of how to use the library from Node.JS:
```javascript

@@ -90,4 +105,4 @@ var sp = require('streaming-percentiles');

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

@@ -97,3 +112,3 @@ <script src="//sengelha.github.io/streaming-percentiles/streamingPercentiles.v1.min.js"></script>

var epsilon = 0.1;
var gk = new streamingPercentiles.GK(epsilon);
var g = new streamingPercentiles.GK(epsilon);
for (var i = 0; i < 1000; ++i)

@@ -107,168 +122,4 @@ g.insert(Math.random());

### Usage Notes
See [doc/api_reference/](doc/api_reference/index.md) for detailed API reference documentation.
- Every algorithm inherits from the interface `stmpct_alg`
which defines two methods: `void insert(double value)`
and `double quantile(double phi) const`.
#### C++
- All include files are in the directory `stmpct/`
- All classes are in the `stmpct` namespace.
#### JavaScript
- For backwards-compatibility reasons, all class names are
capitalized.
### interface stmpct_alg
Defines the interface that all streaming percentile algorithms
must implement.
### void *stmpct_alg*.insert(double *value*)
Logs the observation of a value.
#### C++ Example
```cpp
stmpct_alg* alg = ...;
alg->insert(rand());
```
#### JavaScript Example
```javascript
var alg = ...;
alg.insert(Math.random());
```
### double *stmpct_alg*.quantile(double *phi*) const
Compute the approximate quantile at *phi*. For example, the 95th
percentile corresponds to *phi* = 0.95.
#### C++ Example
```cpp
stmpct_alg* alg = ...;
var p50 = alg->quantile(0.5);
```
#### JavaScript Example
```javascript
var alg = ...;
var p50 = alg.quantile(0.5);
```
### class gk(double *epsilon*)
Implements the Greenwald-Khanna streaming percentile algorithm
with allowable error *epsilon*.
#### C++ Example
```cpp
#include <stmpct/gk.hpp>
stmpct::gk g(0.1);
```
#### JavaScript Example
```javascript
var sp = require('streaming-percentiles');
var gk = new sp.GK(0.1);
```
### class ckms_uq(double *epsilon*)
Implements the Cormode-Korn-Muthukrishnan-Srivastava algorithm
for uniform percentiles with allowable error *epsilon*.
#### C++ Example
```cpp
#include <stmpct/ckms_uq.hpp>
stmpct::ckms_uq c(0.1);
```
#### JavaScript Example
```javascript
var sp = require('streaming-percentiles');
var gk = new sp.CKMS_UQ(0.1);
```
### class ckms_lbq(double *epsilon*)
Implements the Cormode-Korn-Muthukrishnan-Srivastava algorithm
for low-biased quantiles with allowable error *epsilon*.
#### C++ Example
```cpp
#include <stmpct/ckms_lbq.hpp>
stmpct::ckms_lbq c(0.1);
```
#### JavaScript Example
```javascript
var sp = require('streaming-percentiles');
var gk = new sp.CKMS_LBQ(0.1);
```
### class ckms_hbq(double *epsilon*)
Implements the Cormode-Korn-Muthukrishnan-Srivastava algorithm
for high-biased quantiles with allowable error *epsilon*.
#### C++ Example
```cpp
#include <stmpct/ckms_hbq.hpp>
stmpct::ckms_hbq c(0.1);
```
#### JavaScript Example
```javascript
var sp = require('streaming-percentiles');
var gk = new sp.CKMS_HBQ(0.1);
```
### class ckms_tq(vector<targeted_quantile> *tqs*)
Implements the Cormode-Korn-Muthukrishnan-Srivastava algorithm
for the provided set of targeted quantiles *tqs*. Each
targeted quantile is the combination of a quantile *phi* and
allowable error *epsilon*.
#### C++ Example
```cpp
#include <stmpct/ckms_tq.hpp>
std::vector<targeted_quantile> tqs;
tqs.emplace_back(0.125, 0.02);
tqs.emplace_back(0.375, 0.02);
tqs.emplace_back(0.75, 0.04);
tqs.emplace_back(0.875, 0.01);
ckms_tq c(tqs);
```
#### JavaScript Example
```javascript
var sp = require('streaming-percentiles');
var tqs = [
{ phi: 0.125, epsilon: 0.02 },
{ phi: 0.375, epsilon: 0.02 },
{ phi: 0.75, epsilon: 0.04 },
{ phi: 0.875, epsilon: 0.01 }
];
var c = new sp.CKMS_TQ(tqs);
```
## License

@@ -275,0 +126,0 @@

Sorry, the diff of this file is too big to display

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