ProbStructs as easy to use C++ library with probabilistic structures.
Full documentation is available at http://probstructs.readthedocs.io/en/latest/
- CountMinSketch - frequency table of events in a stream
- ExponentialHistorgram - frequency of specific event in the last N elements from a stream
- ExponentialCountMinSketch - frequency table of events in the last N elements from a stream
- Hash - hashing function
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