bounter icon indicating copy to clipboard operation
bounter copied to clipboard

Incorrest hash counting of CountMinSketch

Open awen-li opened this issue 4 years ago • 0 comments

Description

During using the lib CountMinSketch, the counting is unexpected when the item number is larger than the table size.

Steps/Code/Corpus to Reproduce

''' from bounter import CountMinSketch

Cms = None LogCounting = None

def setUp(LogCounting = None): return CountMinSketch(1, width=2, depth=2, log_counting=LogCounting)

Cms = setUp ()

Loop = 8 ItemNum=8

print ("Loop = ", Loop) for i in range (0, Loop): for s in range (0, ItemNum): Cms.increment(str (s))

for s in range (0, 8): print ("Cms[%d] = %d" %(s, Cms[str (s)]))

'''

Expected Results

Cms[0] = 8 Cms[1] = 8 Cms[2] = 0 Cms[3] = 0 Cms[4] = 0 Cms[5] = 0 Cms[6] = 0 Cms[7] = 0

Actual Results

Cms[0] = 22 Cms[1] = 22 Cms[2] = 22 Cms[3] = 24 Cms[4] = 24 Cms[5] = 23 Cms[6] = 23 Cms[7] = 24

Versions

the main branch

awen-li avatar Sep 16 '21 23:09 awen-li