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 18:36:22 +0200 Organization: PointedEars Software (PES) Lines: 44 Message-ID: <1656356.OjxBvjpJ5d@PointedEars.de> References: <87oaksowwg.fsf@Equus.decebal.nl> <1451048.pW9z17ilMA@PointedEars.de> <3158703.Lr4HFMbMOd@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 1433695142 19721 eJwNx8kBwDAIA7CVQokNjMNR9h+h1U9QCtsuwYvFumWdCVYjrP+Why7eRLRluMylwM6jW+NTHyKXEVI= (7 Jun 2015 16:39:02 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Sun, 7 Jun 2015 16:39:02 +0000 (UTC) User-Agent: KNode/4.14.2 X-User-ID: eJwNxskBwCAIBMCWOJZVyhGR/ktI5jXhVN4FBhETs6481x7zYaUfRW5A9GzkWOnuv94Wrk8NFD7mkiqXW2n9ATZoFJI= Cancel-Lock: sha1:MDPwxt7l0zCsXqcRvrTh9Rpopxs= X-NNTP-Posting-Host: eJwFwQkBwDAIA0BLCwTK5PAU/xJ6Z+rwPnRz2tqqEXkEflc4BZSBsdMAU3el5StFcvhH6H0OohC4 Xref: csiph.com comp.lang.python:92271 Chris Angelico wrote: > On Mon, Jun 8, 2015 at 1:51 AM, Thomas 'PointedEars' Lahn > wrote: >> Chris Angelico wrote: >> >>> On Sun, Jun 7, 2015 at 8:40 PM, Thomas 'PointedEars' Lahn >>> wrote: >>>> Cecil Westerhof 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) >>>> >>>> As there is no guarantee that every number will occur randomly, using a >>>> dictionary at first should be more efficient than a list: >>> >>> Hmm, I'm not sure that's actually so. His code is aiming to get >>> 'multiplier' values in each box; for any serious multiplier (he starts >>> with 10 in the main code), you can be fairly confident that every >>> number will come up at least once. >> >> The wording shows a common misconception: that random distribution would >> mean that it is guaranteed or more probable that every element of the set >> will occur at least once. It is another common misconception that >> increasing the number of trials would increase the probability of that >> happening. But that is not so. > > The greater the multiplier, the lower the chance that any element will > have no hits. Wrong. > [ex falso quodlibet] -- PointedEars Twitter: @PointedEars2 Please do not cc me. / Bitte keine Kopien per E-Mail.