https://github.com/martin-majlis/probstructs
Collection of probabilistic data structures - CM-Sketch, ECM-Sketch, exponential histogram in C++.
https://github.com/martin-majlis/probstructs
cpp data-structures probabilistic-programming streaming
Last synced: 12 months ago
JSON representation
Collection of probabilistic data structures - CM-Sketch, ECM-Sketch, exponential histogram in C++.
- Host: GitHub
- URL: https://github.com/martin-majlis/probstructs
- Owner: martin-majlis
- License: mit
- Created: 2020-07-29T04:31:48.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-07-10T08:55:12.000Z (over 1 year ago)
- Last Synced: 2025-02-15T08:24:23.465Z (about 1 year ago)
- Topics: cpp, data-structures, probabilistic-programming, streaming
- Language: C++
- Homepage:
- Size: 77.1 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
Probabilistic Structures
========================
`ProbStructs` as easy to use C++ library with probabilistic structures.
|build-status| |docs| |github-stars-flat|
Documentation
-------------
Full documentation is available at http://probstructs.readthedocs.io/en/latest/
Classes
-------
* `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
.. _CountMinSketch: https://probstructs.readthedocs.io/en/latest/classes.html#countminsketch
.. _ExponentialHistorgram: https://probstructs.readthedocs.io/en/latest/classes.html#exponentialhistorgram
.. _ExponentialCountMinSketch: https://probstructs.readthedocs.io/en/latest/classes.html#exponentialcountminsketch
.. _Hash: https://probstructs.readthedocs.io/en/latest/classes.html#hash
Example
-------
.. code-block:: c++
using namespace probstructs;
ExponentialCountMinSketch 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
.. |build-status| image:: https://travis-ci.org/martin-majlis/probstructs.svg?branch=master
:alt: build status
:target: https://travis-ci.org/martin-majlis/probstructs
.. |docs| image:: https://readthedocs.org/projects/probstructs/badge/?version=latest
:target: http://probstructs.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
.. |github-stars-flat| image:: https://img.shields.io/github/stars/martin-majlis/probstructs.svg?style=flat&label=Stars
:target: https://github.com/martin-majlis/probstructs/
:alt: GitHub stars