From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109d8a,3417cfe6445aca2d X-Google-Attributes: gid109d8a,public X-Google-Thread: 103376,edb23fd6716e96f5 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-09-08 02:04:39 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!193.174.75.178!news-fra1.dfn.de!fu-berlin.de!newsfeed.tli.de!news.tli.de!not-for-mail Message-ID: <3B99DF0C.9BD843F8@talknet.de> From: Hugo Pfoertner X-Mailer: Mozilla 4.73 [de]C-CCK-MCD QXW0324e (Win95; U) X-Accept-Language: en,de MIME-Version: 1.0 Newsgroups: sci.math,comp.lang.ada Subject: Re: basic random number generating methods References: <3B99A61A.7E8E@pointecom.net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Sat, 08 Sep 2001 11:04:12 +0200 NNTP-Posting-Host: 195.252.163.244 X-Complaints-To: abuse@tli.de X-Trace: news.tli.de 999939816 195.252.163.244 (Sat, 08 Sep 2001 11:03:36 CEST) NNTP-Posting-Date: Sat, 08 Sep 2001 11:03:36 CEST Organization: Talkline Internet Division http://www.tli.de Xref: archiver1.google.com sci.math:73435 comp.lang.ada:12925 Date: 2001-09-08T11:04:12+02:00 List-Id: Lynn Killingbeck wrote: > > sachi wrote: > > > > hi, > > I need to generate thousands of instances of n by n-1 tables for n sometimes > > >200, the calculations i do on the tables seem to match the theoretical > > results in some way for large 'n' but for small n say 4 or 6 when i generate > > say 5 instances of them i get lots of repeated rows or even tables. > > I am using ADA 95 random number generator which is a LCG, the numbers being > > generated are then taken modulo of so as to get the desired range. However > > they aint very random.. > > > > ..any suggestions for other generators or anything? > > > > i havent done any background on this whatsoever but how well distributed are > > the digits of pi and can we possibly generate the 'kth' digit or whatever > > using an appropriate function [ok so it may not be very random but well > > distributed will do]?// > > //..sachi > > Sounds from other posts like the Ada standard underlying PRNG is pretty > good. If you are using it, there is yet another popular way to mis-use a > perfectly good generator to get poor results. That way is to re-seed the > generator. If you are re-seeding anywhere in your code, other than just > once at the start and then running your zillions of cases, you can get > your repeated results. Let's say you use "The System" clock to re-seed, > and that clock has a resolution of 1 second. If you re-seed back within > that interval, you will just repeat the previous case. That might > explain why small sizes repeat, but larger ones don't ('cause the clock > has ticked over for the larger ones). Make sure you are not re-seeding > for each case. > > Of course, you can also get into trouble by using too much of the period > of the generator, but if it is something like 2^49 that's unlikely. > > Do you know such things as the clock resolution on your platform? How > many bits it has? If there are not a lot of bits, you will also get > repetitions if you re-seed, but in that case I would expect the repeats > to be for both big and small. > > Just for your amusement, I'll quote a bit from Plaugher's "The Standard > C Library" on the topic of in chapter 15. You make the call on > whether the Ada language acts the same, or if Ada refuses to even run on > a platform with inadequate time resolution and precision. The side-bar > is called "weasel words": "A vendor could argue that 1 January 1980 is > always the best available approximation to any time and date. A customer > can rightly quarrel about the low quality of such an approximation, but > not whether it satisfies the C Standard." So, if you are seeding with > "The System" time, and your particular "The System" happens to return a > constant value (meeting formal standards!) - reach your own conclusion. > I'll let the Ada Language-Lawyers have their fun with this one. > > Lynn Killingbeck The Ada95 Performance Requirements for RNG require: "Two different calls to the time-dependent Reset procedure shall reset the generator to different states, provided that the calls are separated in time by at least one second and not more than fifty years." It is then dependent on the implementation of the "calendar.seconds()" function, if a reset within one simulation run generates the same sequence or not. With GHz++ processors, its not so unlikely that exactly the same time value is returned, even if the "seconds" function has ms resolution. That might be an issue, when moveing old programs, that have been designed some years ago, are now executed on high performance platforms. Hugo