Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.python Subject: Re: Testing random Date: Sun, 07 Jun 2015 22:15:49 +0200 Organization: PointedEars Software (PES) Lines: 35 Message-ID: <2115433.UTq2kp7hT1@PointedEars.de> References: <87oaksowwg.fsf@Equus.decebal.nl> <55743ea4$0$13004$c3e8da3$5496439d@news.astraweb.com> <1586765.9ka6YhQpJC@PointedEars.de> Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Trace: solani.org 1433708309 1790 eJwFwQkBwDAIA0BLKyUw5PAE/xJ6h2vH2tVgisUOkRU2uT2XP3MW6v2NyMYUNcmQsqPtROEBUUUSuA== (7 Jun 2015 20:18:29 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Sun, 7 Jun 2015 20:18:29 +0000 (UTC) User-Agent: KNode/4.14.2 X-User-ID: eJwNyckBwCAMA7CVgNgJjJNz/xFafUXRrWlQKjicaNeUuIMjKq/w3/N1hGiNCQ/IXk3cRPV4aB1Yv1tptOEHYkIV/Q== Cancel-Lock: sha1:lEXay3xHVvHu20ryO7rqOEns44c= X-NNTP-Posting-Host: eJwVytEVwEAEBMCWcOxGOeHov4S8zPfEgaLpCHhsrPOFuU/eo4/Q7nJUrcKmFkORzEJP0/CnDw2REN0= Xref: csiph.com comp.lang.python:92300 Peter Otten wrote: > 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 ;) The details are in my other follow-ups. Go read them. -- PointedEars Twitter: @PointedEars2 Please do not cc me. / Bitte keine Kopien per E-Mail.