Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.04; 'bits': 0.07; 'hettinger': 0.07; 'names.': 0.07; 'recipe': 0.07; 'terry': 0.07; '>>>>': 0.09; 'hash': 0.09; 'presume': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'pm,': 0.11; 'wrote:': 0.14; '(24,': 0.16; 'lengths': 0.16; 'matched': 0.16; 'negatives': 0.16; 'reedy': 0.16; 'tries': 0.16; "wouldn't": 0.18; 'jan': 0.22; 'header:In-Reply-To:1': 0.22; 'raymond': 0.22; 'runs': 0.24; 'example': 0.24; 'produced': 0.26; 'skip:b 20': 0.27; 'pass': 0.27; 'tried': 0.27; 'skip:p 30': 0.29; 'good.': 0.29; '(the': 0.30; 'comment': 0.30; 'yields': 0.31; 'it.': 0.31; 'random': 0.31; 'to:addr:python-list': 0.32; 'test': 0.33; 'header:X-Complaints-To:1': 0.34; 'header:User-Agent:1': 0.35; 'should': 0.37; 'resulting': 0.38; 'strings': 0.38; 'but': 0.38; 'reasonable': 0.38; 'received:org': 0.38; 'to:addr:python.org': 0.39; 'header:Mime-Version:1': 0.39; 'works': 0.40; 'would': 0.40; "it's": 0.40; 'header:Received:5': 0.40; 'geographic': 0.60; 'show': 0.67; 'states': 0.69; 'average': 0.77; 'by,': 0.84; 'pass:': 0.84; '100000': 0.91; 'fifty': 0.91; '100,000': 0.93; 'subject:Today': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Today's fun and educational Python recipe Date: Wed, 04 May 2011 20:26:51 -0400 References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: rain.gmane.org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.17) Gecko/20110414 Lightning/1.0b2 Thunderbird/3.1.10 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 42 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1304555226 news.xs4all.nl 81484 [::ffff:82.94.164.166]:34621 X-Complaints-To: abuse@xs4all.nl Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.stben.net!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:4675 On 5/4/2011 5:39 PM, Raymond Hettinger wrote: > The 512 bits in h are progressively eaten-up between iterations. So > each pass yields a different (array index, bit_mask) pair. Yeh, obvious now that I see it. > It's easy to use the interactive prompt to show that different probes > are produced on each pass: > >>>> bf = BloomFilter(num_bits=1000, num_probes=8) >>>> pprint(list(bf.get_probes('Alabama'))) > [(19, 1073741824), > (11, 64), > (9, 134217728), > (25, 1024), > (24, 33554432), > (6, 16), > (7, 16777216), > (22, 1048576)] Should have tried that. > The 512 bits are uncorrelated -- otherwise sha512 wouldn't be much of > a cryptographic hash ;) > The fifty state example in the recipe is a reasonable demonstration > that the recipe works as advertised. It successfully finds all fifty > states (the true positives) and it tries 100,000 negatives resulting > in only a handful of false negatives. I presume you mean 'false positives', as in the program comment and Wikipedia. The test would be more convincing to many with 100000 other geographic names (hard to come by, I know), or other english names or words or even with longer random strings that matched the lengths of the state names. But an average of 5/100000 false positives in 5 runs is good. -- Terry Jan Reedy