🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #23217

Re: CRC64 test results

#23217
From: Matt Dillon
Date: Thu, 13 Nov 1997 00:00
57 lines
2915 bytes
    b	- number of bits in hash
    n	- number of words in database
    c	- number of hash collisions that will occur if you attempt to hash n 
	  words and have a b bit hash key, assuming a good hash function.

    c = ( n * (n-1) / 2 ) / 2^b

    So, for example, if you have a 16 bit hash and 1000 words in your database,
    there will be approximately 7.6 collisions.

    Now here's the interesting thing.  If you have 10000 words in your 
    database and you use a 16 bit hash, there will be 762 collisions.

    If you have 100,000 words in your database, there will be over 76290
    collisions.  If you think about it, it makes sense... a 16 bit hash
    key can only generate 65536 unique hash values and you are trying to
    hash 100,000 words.

    ok, it breaks down.. if you have 10M words and a 16 bit hash, the above
    equation returns 762M collisions, which is not possible since you had
    only a 10M word dataset.  The problem is that we do not take into account
    a prior collision *reducing* the chance of a later collision by not
    finding an unused slot in the hash.  Thus the equation only works well
    for 2^B substantially larger then N.

    If you try to hash 100M words with a 32 bit key, there will be 
    approximately 1.1M collisions.  That is, even though the 32 bit key
    has 4 billion possible hash values and you are only doing 100M
    words, you still get 1.1M collisions.

    If you try to hash 100M words with a 48 bit key, there will be
    approximately 17.7 collisions.

    If you try to hash 100M words with a 52 bit key, there will be
    approximately 1 collision.

    To get one collision with a N words and a B bit key, solving for N
    given c = 1 and simplifying the equation by changing (N-1) to (N), to:

    c = ( n * n / 2 ) / 2^b		(simplified, some accuracy lost)
    n * n = c * 2 * 2^b
    n = sqrt(1.0 * 2 * 2^b)

    So, to get one collision with a 64 bit key requires you to hash
    approximately 6 billion words.

    To get one collision with a 56 bit key requires you to hash
    approximately 379M words.

    Isn't this fun ?  I love numbers.

						-Matt



Technical Details
Message-ID: <64gh6g$ob5$1@flea.best.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
References: <64a6pf$ejq$1@flea.best.net> <64b64b$hcb@dfw-ixnews1.ix.netcom.com> <0000346B688D.NO_UCE@mauve.demon.co.uk> <0000346BB22C.NO_UCE@mauve.demon.co.uk>

Show Full Headers
Complete Article Headers
Message-ID: <64gh6g$ob5$1@flea.best.net>
Subject: Re: CRC64 test results
Date: Thu, 13 Nov 1997 00:00:00 +0000
From: dillon@best.net (Matt Dillon)
References: <64a6pf$ejq$1@flea.best.net> <64b64b$hcb@dfw-ixnews1.ix.netcom.com> <0000346B688D.NO_UCE@mauve.demon.co.uk> <0000346BB22C.NO_UCE@mauve.demon.co.uk>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
X-Deja-AN: 289404870
X-Trace: 879478802 29342 dillon 206.184.139.132
Organization: Best Internet Communications, Inc. - 650 964 BEST
Newsgroups: news.software.nntp