Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!news2.arglkargh.de!news.swapon.de!eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; '[0]': 0.07; 'counting': 0.07; 'indices': 0.07; 'pointless': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'def': 0.14; 'hits': 0.16; 'index.': 0.16; 'pythonic': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'subject:random': 0.16; 'wrote:': 0.16; '>>>': 0.20; 'wrote': 0.23; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'function': 0.30; "skip:' 10": 0.30; 'putting': 0.31; 'table': 0.32; 'aside': 0.32; 'common': 0.33; "d'aprano": 0.33; 'steven': 0.33; 'minimum': 0.35; 'to:addr:python-list': 0.35; 'done': 0.35; 'but': 0.36; 'agree': 0.37; 'subject:: ': 0.37; 'received:org': 0.38; 'test': 0.39; 'to:addr:python.org': 0.39; 'received:de': 0.40; 'your': 0.60; 'maximum': 0.61; 'per': 0.61; 'simple': 0.61; 'thomas': 0.63; 'skip:n 10': 0.63; '10000': 0.66; 'frequency': 0.66; 'calculations': 0.84; 'otten': 0.84; 'subject:Testing': 0.84; 'average': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Peter Otten <__peter__@web.de> Subject: Re: Testing random Date: Sun, 07 Jun 2015 18:48:01 +0200 Organization: None References: <87oaksowwg.fsf@Equus.decebal.nl> <55743ea4$0$13004$c3e8da3$5496439d@news.astraweb.com> <1586765.9ka6YhQpJC@PointedEars.de> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Gmane-NNTP-Posting-Host: p57bd8268.dip0.t-ipconnect.de User-Agent: KNode/4.13.3 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1433695702 news.xs4all.nl 2858 [2001:888:2000:d::a6]:59325 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:92273 Thomas 'PointedEars' Lahn wrote: > Peter Otten wrote: > >> Steven D'Aprano wrote: >>>> I wrote a very simple function to test random: >>>> def test_random(length, multiplier = 10000): >>>> number_list = length * [0] >>>> for i in range(length * multiplier): >>>> number_list[random.randint(0, length - 1)] += 1 >>>> minimum = min(number_list) >>>> maximum = max(number_list) >>>> return (minimum, maximum, minimum / maximum) >>> >>> Putting aside the timing aspects, your frequency calculations are not >>> done in a very Pythonic manner. >> >> I would agree if the frequency table were sparse, i. e. many indices with >> >> number_list[index] == 0 >> >> but that's not the case with on average 10000 hits per index. > > A common misconception. A pointless remark. Not counting the ears ;)