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: 103376,c7fc42d2c6a0eedc X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-04-04 02:22:42 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!arclight.uoregon.edu!enews.sgi.com!news.xtra.co.nz!newsfeed01.tsnz.net!ken-transit.news.telstra.net!news.telstra.net!news-server.bigpond.net.au!not-for-mail From: Dale Stanbrough Newsgroups: comp.lang.ada Subject: Re: Ada2005 random References: User-Agent: MT-NewsWatcher/3.3b1 (PPC Mac OS X) Message-ID: Date: Fri, 04 Apr 2003 10:21:44 GMT NNTP-Posting-Host: 144.132.47.50 X-Complaints-To: abuse@bigpond.net.au X-Trace: news-server.bigpond.net.au 1049451704 144.132.47.50 (Fri, 04 Apr 2003 20:21:44 EST) NNTP-Posting-Date: Fri, 04 Apr 2003 20:21:44 EST Organization: BigPond Internet Services (http://www.bigpond.net.au) Xref: archiver1.google.com comp.lang.ada:35919 Date: 2003-04-04T10:21:44+00:00 List-Id: Randy Brukardt wrote: > I needed that for a 'choosing' algorithm, say drawing balls one by one > out of a bowl. If you have 8 balls originally, you're choosing 1 out of > 7, then 1 out of 6, etc. If you try to use 1 out of 8 the whole time and > discarding the useless ones, the second last draw can take a very long > time (only 2 out of 8 choices are meaningful). I'm pretty sure that this > is a valid technique; certainly the underlying float generator is still > random (at least as much as it ever was!), and the use of that result is > unbiased. > > While it would be nice if Ada supported this directly, it's easy enough > to write it yourself. How about for i in reverse 8..2 loop put (random (blah) mod i); end loop; ? dale