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-03 14:09:59 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!sn-xit-03!sn-xit-06!sn-post-02!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Ada2005 random Date: Thu, 3 Apr 2003 16:10:36 -0600 Organization: Posted via Supernews, http://www.supernews.com Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Newsreader: Microsoft Outlook Express 4.72.3612.1700 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3719.2500 X-Complaints-To: abuse@supernews.com Xref: archiver1.google.com comp.lang.ada:35908 Date: 2003-04-03T16:10:36-06:00 List-Id: Peter Hermann wrote in message ... >David C. Hoos, Sr. wrote: >> Such an approach is statistically dubious, since the same generator is >> being used for all draws. Normally, one would use a distinct >> generator for each sequence. > >agreed: this is of course not a purist's approach >although I could live with it in the practice. >Using Lutz Do's code (thank you) should do the job. >Do you have a better idea how to pick out randomly from a set with >an always changing number of members? When I wanted to do that, I just borrowed the code from the Ada random number generator. In all of the implementations I've seen, the actual generator is the float one; the integer one just uses some code to return the proper value. I just made a function that did that with variable bounds instead of the generic ones. 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. Randy Brukardt.