1234567891011121314151617181920212223242526272829303132333435363738394041424344454647# 1 "src/base/misc/owl_countmin_sketch_sig.ml"(* An implementation of the Count-Min sketch introduced by
* Cormode and Muthukrishnan. The Count-Min sketch provides an approximate
* frequency table whose space and time complexity are independent of the
* number of elements inserted. It provides the following guarantee:
* - Estimated frequency >= True frequency
* - With probability at least 1 - delta:
* Estimated frequency - True frequency < epsilon * L
* where L is the L1 norm of the data entered, equal to the total number of
* times `incr` has been called.
* Space usage will be O((1/epsilon) log (1/delta)) and the time to complete
* `incr` or `count` will be O(log(1/delta)).
* Refer to http://dimacs.rutgers.edu/~graham/pubs/papers/cm-full.pdf
* for more details. *)moduletypeSig=sig(** {5 Type definition} *)type'asketch(** The type of Count-Min sketches *)(** {5 Core functions} *)valinit:epsilon:float->delta:float->'asketch(**
``init epsilon delta`` initializes a sketch with approximation ratio
``(1 + epsilon)`` and failure probability ``delta``.
*)valincr:'asketch->'a->unit(** ``incr s x`` increments the frequency count of ``x`` in sketch ``s`` in-place. *)valcount:'asketch->'a->int(** ``count s x`` returns the estimated frequency of element ``x`` in ``s``. *)valinit_from:'asketch->'asketch(**
``init_from s`` initializes a new empty sketch with the same parameters as ``s``, which
can later be merged with ``s``.
*)valmerge:'asketch->'asketch->'asketch(**
``merge s1 s2`` returns a new sketch whose counts are the sum of those in ``s1`` and ``s2``.
Raises ``INVALID_ARGUMENT`` if the parameters of ``s1`` and ``s2`` do not match.
*)end