Skip to content

Collection of probabilistic data structures - CM-Sketch, ECM-Sketch, exponential histogram in C++.

License

Notifications You must be signed in to change notification settings

martin-majlis/probstructs

Repository files navigation

Probabilistic Structures

ProbStructs as easy to use C++ library with probabilistic structures.

build status Documentation Status GitHub stars

Documentation

Full documentation is available at http://probstructs.readthedocs.io/en/latest/

Classes

Example

using namespace probstructs;

ExponentialCountMinSketch<int> sketch(100, 4, 8);

uint ts = 0;

ts = 0;
sketch.inc("aaa", ts, 1);
sketch.inc(std::string("bbb"), ts, 4);
sketch.inc("ccc", ts, 8);

std::cerr << sketch.get(std::string("aaa"), 4, ts) << std::endl;
// 1

std::cerr << sketch.get("bbb", 4, ts) << std::endl;
// 4

std::cerr << sketch.get("ccc", 4, ts) << std::endl;
// 8

std::cerr << sketch.get("ddd", 4, ts) << std::endl;
// 0

ts = 4;
std::cerr << sketch.get("aaa", 2, ts) << std::endl;
// 0
std::cerr << sketch.get("bbb", 2, ts) << std::endl;
// 0
std::cerr << sketch.get(std::string("ccc"), 2, ts) << std::endl;
// 0
std::cerr << sketch.get("ddd", 2, ts) << std::endl;
// 0

std::cerr << sketch.get("aaa", 8, ts) << std::endl;
// 1
std::cerr << sketch.get("bbb", 8, ts) << std::endl;
// 4
std::cerr << sketch.get("ccc", 8, ts) << std::endl;
// 8
std::cerr << sketch.get("ddd", 8, ts) << std::endl;
// 0