Calculating Percentiles on Streaming Data Part 5: C++ Library
Calculating Percentiles on Streaming Data
Published: 2018-03-09
Calculating Percentiles on Streaming Data Part 5: C++ Library

This is part 5/8 of my Calculating Percentiles on Streaming Data series.

I have created a reusable C++ library which contains my implementation of the streaming percentile algorithms found within this blog post and published it to GitHub. Here’s what using it looks like:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
#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

You can find it here: