Class: CountMinSketch
Defined in: count-min.ts:39 Sub-linear-memory frequency estimator. Estimates the number of times a string has been observed usingO(width × depth) memory regardless of the cardinality of the keyspace.
Estimates satisfy estimate(x) ≥ trueCount(x) and, with probability
≥ 1 − delta, estimate(x) ≤ trueCount(x) + epsilon · totalCount.
Parameters:
width = ⌈ e / epsilon ⌉(columns per row)depth = ⌈ ln(1 / delta) ⌉(independent hash rows)
Example
Constructors
Constructor
new CountMinSketch(Defined in: count-min.ts:52epsilon,delta):CountMinSketch
Parameters
epsilon
number
Additive error bound, in (0, 1). Smaller ⇒ more
memory, tighter estimates.
delta
number
Probability that the error bound is exceeded, in
(0, 1). Smaller ⇒ more rows.
Returns
CountMinSketch
Throws
RangeError if either parameter is outside(0, 1).
Methods
estimate()
estimate(Defined in: count-min.ts:92key):number
Parameters
key
string
Returns
number
An over-estimate of the number of times key has been
incremented. Never returns less than the true count.
increment()
increment(Defined in: count-min.ts:80 Addkey,count?):void
count to the running tally for key.
Parameters
key
string
The item being counted.
count?
number = 1
Increment amount; defaults to 1. Negative counts are
permitted but break the upper-bound guarantee.
Returns
void