package grenier
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=b08e4c774ef72fc53c4fcee477e739d1beac9702079300daddf51ced9fa9cd26
sha512=984d92c51dac7b3f169cad595969a4fdbeb2be7b420ed1a85618d6adbb64af855cf2618d9bd0834e84d6734b99196944cab04435e1aeacad8cdfbc9a7f73d6d4
doc/grenier.hll/Hll/index.html
Module Hll
Source
An implementation of HyperLogLog probabilistic cardinality estimator.
Type of HyperLogLog counters
Create a new counter with error
error rate. error
should verify 0.0 < error && error < 1.0
. 0.05
is a reasonable default.
Use estimate_memory
to measure memory consumption and runtime of this function.
add t k
counts item k
in t
.
k
should be "random": it should be the output of some cryptographic hashing algorithm like SHA. It is not treated as an integer. This is key to getting proper results. No patterns should appear in the bits of the different items added.
Runtime is O(1).
Estimate the memory consumed in bytes by a counter with the specified error rate.
This ignores the constant overhead of the OCaml representation, around two words. It is a bytes
of estimate_memory ~error + 1
length.
merge ~into:t0 t'
has the same effect as adding all items added to t'
to t0
.
t0
and t'
must have been constructed with the same error rate!
The following algorithm provide a reasonable hashing function for integers, if you want to feed the HLL with "normal" integers.