Article View: comp.lang.basic.misc
Article #108Random errors :-) [Was: Random number question?]
From: Phred
Date: Wed, 23 Jun 2004 12:15
Date: Wed, 23 Jun 2004 12:15
72 lines
4212 bytes
4212 bytes
In article <1096976264.1684.1096967182@bayman.org>, david.williams@bayman.org (David Williams) wrote: >-> > RND is not truly random, of course, but it's a VERY good simulation of >-> > randomness. Almost all programs that allegedly show RND to be >-> > non-random are in fact badly-written programs that really show nothing >-> > of the kind. > >-> Marsaglia's 1968 paper showed exactly the opposite, so I would be interested > >-> to know which programs you are referring to. VB and QB have LCRNGs of >-> exactly the type Marsaglia examined - see > >I did say *almost* all. Yes, Certainly, anyone who knows how a >RND-generator works can write a program that shows it not to be truly >random. The little thing I wrote yesterday, re-seeding the generator >with the same number and showing it then produces the same RNDs is just >one example. > >But the vast majority of little BASIC programs that allegedly show RND >to be non-random have been written by amateurs who really don't know >what they are doing. For example, they re-seed the generator over and >over again from TIMER, in such a short interval of time that it has the >same value. I dudded myself in a similar way 30 years ago using FORTRAN on a DEC System-10. I decided to print out a series of random number sets for use in the field when I escaped once more from academia, and when I came to use the sets a year or two later I discovered they were all the same sequence of numbers! Another fine example of the consequences of ignoring the injunction to RTFM. 8-) Another trap I caught myself with as a result of more confidence than competence was in randomising a set of 10 individuals of each of 30 species into a fully random field design (i.e. no blocking). I allocated each randomly chosen species/individual to a sequential field position and wondered why I ended up with a preponderance of one or two species at the end of the paddock! In its simplest form, what I *should* have done was allocate a randomly chosen field position to each species/individual combination. >(Anecdote coming up:) Many years ago, a friend of mine ran a small >Bulletin Board System. Just for fun, he incorporated a lottery game >into it. Every day, users "bet" on sequences of numbers. Each night, >the computer generated its own sequence, using RNDs, and then rewarded >whoever had got the most numbers right with an extended membership of >the BBS. > >There was just one problem. The machine kept coming up with the same >numbers! My friend, who had written the code himself, tested it many >times, and couldn't find anything wrong. After a *long* time, he >realized the problem. At the start of his code, he had written: > >X=RND(-TI) > >(This was in Commodore BASIC, in which TI was a timer that ran in 60ths >of a second, starting at midnight. The above line was the standard way >to "randomly" seed the RND generator.) > >But, when it was running automatically, the BBS computer was executing >the lottery code at exactly the same time, by its own clock, every >night. So TI always had the same value. That's why the numbers the >computer chose were always the same. > >Simply removing the re-seeding line and replacing it right at the >beginning of the program, where it was executed only once as the BBS >was set up, fixed the problem. Cheers, Phred. -- ppnerkDELETE@THISyahoo.com.INVALID
Technical Details
Message-ID:
<2jtaihFv915pU1@uni-berlin.de>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!not-for-mailReferences:
<1096976264.1684.1096967182@bayman.org>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10c949,e67e774439767f3d X-Google-Thread: 108c83,641e1535c1b5b983,start X-Google-Attributes: gid10c949,gid108c83,public Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!not-for-mail From: ppnerkDELETETHIS@yahoo.com (Phred) Newsgroups: comp.lang.basic.misc,aus.computers Subject: Random errors :-) [Was: Random number question?] Date: Wed, 23 Jun 2004 12:15:51 GMT Organization: Just me Lines: 73 Message-ID: <2jtaihFv915pU1@uni-berlin.de> References: <1096976264.1684.1096967182@bayman.org> X-Trace: news.uni-berlin.de Nr2mZVtCsOgyY2EQx7sCxws0cfuhSBnLuoaynuBox3tkaaAhRe X-Orig-Path: Telstra X-Newsreader: News Xpress 2.01