Path: csiph.com!usenet.pasdenom.info!bete-des-vosges.org!news.redatomik.org!newsfeed.xs4all.nl!newsfeed2.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.037 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'finite': 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; '...,': 0.16; 'adjacent': 0.16; 'cyclic': 0.16; 'message- id:@4ax.com': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:random': 0.16; 'alternate': 0.18; 'say,': 0.18; 'url:home': 0.18; 'widely': 0.18; '>>>': 0.20; 'parameter': 0.22; '2015': 0.23; 'second': 0.24; 'testing': 0.25; 'example': 0.25; 'header:X-Complaints-To:1': 0.26; '+0200,': 0.27; 'sequence': 0.27; 'equally': 0.29; 'measure': 0.29; 'random': 0.29; 'function': 0.30; 'print': 0.31; 'ideal': 0.32; 'case,': 0.34; 'could': 0.35; 'to:addr:python- list': 0.35; 'but': 0.36; 'being': 0.36; 'there': 0.36; 'should': 0.37; 'subject:: ': 0.37; 'charset:us-ascii': 0.37; 'received:org': 0.38; 'is,': 0.38; 'expect': 0.39; 'to:addr:python.org': 0.39; 'skip:u 10': 0.62; '(that': 0.63; 'between': 0.65; 'differences': 0.66; 'intent': 0.66; 'ranges': 0.76; '10th': 0.84; 'cecil': 0.84; 'expect.': 0.84; 'subject:Testing': 0.84; 'westerhof': 0.84; 'dennis': 0.91; 'increases': 0.91; 'received:108': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: Testing random Date: Sun, 07 Jun 2015 11:04:37 -0400 Organization: IISS Elusive Unicorn References: <87oaksowwg.fsf@Equus.decebal.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-108-73-119-127.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES 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: 66 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1433689486 news.xs4all.nl 2867 [2001:888:2000:d::a6]:45223 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:92259 On Sun, 07 Jun 2015 08:27:59 +0200, Cecil Westerhof declaimed the following: > >It shows that when the first parameter increases the deviation >increases and when the second parameter increases the deviation >decreases. Exactly what you would expect. But what are the ranges you >would expect with a good random function. Then it could be used to >test a random function. From what I could make out, you are testing the distribution of an equally weighted function (that is, any value in the lower..upper range is equally likely to appear). Unfortunately, a measure of distribution shows nothing for predictability (non-randomness). Here's an example displaying ideal distribution (I should have made the first for-loop a generator) >>> def lin(smpl=10000): ... samples = {} ... for i in range(smpl): ... samples[i % 10] = samples.get(i % 10, 0) + 1 ... for i in range(10): ... print i, samples[i] ... >>> lin() 0 1000 1 1000 2 1000 3 1000 4 1000 5 1000 6 1000 7 1000 8 1000 9 1000 >>> lin(9876) 0 988 1 988 2 988 3 988 4 988 5 988 6 987 7 987 8 987 9 987 >>> But is it random? Only in that there is a finite chance of a truly random sequence being: 0, 1, 2, 3, 4, ..., 8, 9, 0, 1, ... If the distribution is widely uneven, the odds are the generator is not random -- or at least, not random in the equally weighted sense; it may be perfectly random gaussian or Poisson distribution. For the equally weighted case, one may need to also compute, say, differences between adjacent samples, between alternate samples, between every 10th sample, whatever... with the intent being to reveal if there is any cyclic pattern detectable. -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/